|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.entityfs.util.obs.polling.PollingDirectoryMonitorer
public class PollingDirectoryMonitorer
This class polls a directory and generates events when it detects changes. It
is used for detecting changes that are made from other processes, for
instance for monitoring a directory for incoming files.
EntityObserver
objects register themselves as listeners to instances
of this class.
The directory is polled every time an outside ticker generates an
event. A ticker is any kind of Observable
, for instance a
TimerTicker
. An application that does not want to start its own
threads (maybe because it is running in an application server) can use a JMX
timer.
The following events are generated:
ChildEntitiesAddedEvent
— child entities have been added
since last polling the directory.ChildEntitiesModifiedEvent
— child entities have been
modified in a way that updated their last modification times.ChildEntitiesRemovedEvent
— child entities have been
removed from the directory.ChildEntitiesStabilizedEvent
— added or modified child
entities have been stabilized. An entity is stabilized when it has not
been modified in a configurable amount of time.
This monitorer does not generate any events until it is start()
:ed.
The monitorer uses a ErrorHandlingStrategy
for dealing with errors
from EntityObserver
:s. The default strategy,
LoggingErrorHandlingStrategy
rethrows all errors that it encounters.
This can potentially break the ticker if it is not implemented to
handle exceptions from its observers.
Field Summary | |
---|---|
static long |
DEFAULT_STABILIZED_LIMIT_MSECS
Five seconds. |
Constructor Summary | |
---|---|
PollingDirectoryMonitorer(DirectoryView dv,
Observable ticker)
|
|
PollingDirectoryMonitorer(DirectoryView dv,
Observable ticker,
ErrorHandlingStrategy ehs)
|
Method Summary | |
---|---|
void |
addObserver(EntityObserver obs)
Add an observer. |
int |
countObservers()
Get the number of observers. |
void |
deleteObserver(EntityObserver obs)
Delete an observer. |
void |
deleteObservers()
Delete all observers. |
DirectoryView |
getDirectoryView()
Get the monitored directory. |
ErrorHandlingStrategy |
getErrorHandlingStrategy()
|
long |
getStabilizedLimitMSecs()
|
long |
getTimestampOfLastEvent()
Get the timestamp of the last event fired from this object. |
void |
setStabilizedLimitMSecs(long limit)
|
void |
start()
Start the monitorer. |
void |
stop()
Stop the monitorer. |
void |
update(Observable obs,
Object o)
This is called by the ticker when it is time to poll the monitored directory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long DEFAULT_STABILIZED_LIMIT_MSECS
Constructor Detail |
---|
public PollingDirectoryMonitorer(DirectoryView dv, Observable ticker)
public PollingDirectoryMonitorer(DirectoryView dv, Observable ticker, ErrorHandlingStrategy ehs)
Method Detail |
---|
public void setStabilizedLimitMSecs(long limit)
public long getStabilizedLimitMSecs()
public void addObserver(EntityObserver obs)
addObserver
in interface Observable
obs
- The observer.public void deleteObserver(EntityObserver obs)
deleteObserver
in interface Observable
obs
- The observer.public void deleteObservers()
deleteObservers
in interface Observable
public int countObservers()
countObservers
in interface Observable
public ErrorHandlingStrategy getErrorHandlingStrategy()
public long getTimestampOfLastEvent()
System.currentTimeMillis()
timestamp.)
getTimestampOfLastEvent
in interface DirectoryMonitorer
public void start()
The monitorer can be stopped by calling stop()
.
start
in interface DirectoryMonitorer
public void stop()
start()
is called.
stop
in interface DirectoryMonitorer
public void update(Observable obs, Object o)
update
in interface Observer
public DirectoryView getDirectoryView()
getDirectoryView
in interface DirectoryMonitorer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |