org.apache.avalon.excalibur.monitor
Class Resource

java.lang.Object
  extended byorg.apache.avalon.excalibur.monitor.Resource
All Implemented Interfaces:
Modifiable
Direct Known Subclasses:
DirectoryResource, StreamResource

public abstract class Resource
extends java.lang.Object
implements Modifiable

Managed Resource. All resources must have a constructor that takes a String and converts it to the needed format (i.e. File). A Managed Resource in the Monitor section has only one property needed to be changed: last modified. The property name for the last modified event will be the same as the resource key. Implementations may add additional properties, but for most instances the last modified property will be enough.

Version:
$Id: Resource.java,v 1.4 2004/02/28 11:47:32 cziegeler Exp $
Author:
Avalon Development Team

Field Summary
protected  java.beans.PropertyChangeSupport m_eventSupport
          Deprecated. Developers should use the setter/getters associated with field.
protected  long m_previousModified
          Deprecated. Developers should use the setter/getters associated with field.
protected static java.lang.String MODIFIED
           
 
Constructor Summary
Resource(java.lang.String resourceKey)
          Required constructor.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          This is the prefered method of registering a PropertyChangeListener.
protected  void addPropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
          This is a convenience if you want to expose other properties for the Resource.
 void addPropertyChangeListenersFrom(Resource other)
          Abstract method to add the PropertyChangeListeners in another Resource to this one.
protected  void fireAndSetModifiedTime(long lastModified)
          Fire a modify event and set the lastModified time as appropraite.
protected  java.beans.PropertyChangeSupport getEventSupport()
           
protected  long getPreviousModified()
           
 java.lang.String getResourceKey()
          Return the key for the resource.
 boolean hasListeners()
          This is the preferred method of determining if a Resource has listeners.
protected  boolean hasListeners(java.lang.String property)
          This is a convenience if you want to expose other properties for the Resource.
abstract  long lastModified()
          The time this was last modified.
 void removeAllPropertyChangeListeners()
          This cleanup method removes all listeners
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          This is the prefered method of unregistering a PropertyChangeListener.
protected  void removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
          This is a convenience if you want to expose other properties for the Resource.
protected  void setPreviousModified(long previousModified)
           
 void testModifiedAfter(long time)
          Test whether this has been modified since time X
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODIFIED

protected static final java.lang.String MODIFIED
See Also:
Constant Field Values

m_eventSupport

protected java.beans.PropertyChangeSupport m_eventSupport
Deprecated. Developers should use the setter/getters associated with field.


m_previousModified

protected long m_previousModified
Deprecated. Developers should use the setter/getters associated with field.

Constructor Detail

Resource

public Resource(java.lang.String resourceKey)
         throws java.lang.Exception
Required constructor. The String location is transformed by the specific resource monitor. For instance, a FileResource will be able to convert a string representation of a path to the proper File object.

Method Detail

getResourceKey

public final java.lang.String getResourceKey()
Return the key for the resource.


lastModified

public abstract long lastModified()
The time this was last modified.

Specified by:
lastModified in interface Modifiable

testModifiedAfter

public void testModifiedAfter(long time)
Test whether this has been modified since time X

Specified by:
testModifiedAfter in interface Modifiable

fireAndSetModifiedTime

protected void fireAndSetModifiedTime(long lastModified)
Fire a modify event and set the lastModified time as appropraite.

Parameters:
lastModified - the time modified at

addPropertyChangeListenersFrom

public void addPropertyChangeListenersFrom(Resource other)
Abstract method to add the PropertyChangeListeners in another Resource to this one.


addPropertyChangeListener

public final void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
This is the prefered method of registering a PropertyChangeListener. It automatically registers the listener for the last modified event.


addPropertyChangeListener

protected void addPropertyChangeListener(java.lang.String property,
                                         java.beans.PropertyChangeListener listener)
This is a convenience if you want to expose other properties for the Resource. It is protected now, but you may override it with public access later.


removePropertyChangeListener

public final void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
This is the prefered method of unregistering a PropertyChangeListener. It automatically registers the listener for the last modified event.


removePropertyChangeListener

protected void removePropertyChangeListener(java.lang.String property,
                                            java.beans.PropertyChangeListener listener)
This is a convenience if you want to expose other properties for the Resource. It is protected now, but you may override it with public access later.


hasListeners

public final boolean hasListeners()
This is the preferred method of determining if a Resource has listeners.


removeAllPropertyChangeListeners

public void removeAllPropertyChangeListeners()
This cleanup method removes all listeners


hasListeners

protected boolean hasListeners(java.lang.String property)
This is a convenience if you want to expose other properties for the Resource. It is protected now, but you may override it with public access later.


getPreviousModified

protected final long getPreviousModified()

setPreviousModified

protected final void setPreviousModified(long previousModified)

getEventSupport

protected final java.beans.PropertyChangeSupport getEventSupport()

toString

public java.lang.String toString()


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.