Package gov.usgs.util
Class DirectoryPoller
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.util.DirectoryPoller
- All Implemented Interfaces:
Configurable
,Poller
Monitor a directory for files, notifying FileListenerInterfaces.
Implementers of the FileListenerInterface should process files before
returning, because these files may move or disappear.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Default errorDirectorystatic final String
Default status of POLL_CAREFULLYstatic final String
Default pollDirectorystatic final String
Default interval for POLLINTERVALstatic final String
Default storageDirectorystatic final String
Property for errorDirectorystatic final String
Property for pollCarefullystatic final String
Property for pollDirectorystatic final String
Poll interval propertystatic final String
Property for storageDirectory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFileListener
(FileListenerInterface listener) void
Process configuration settings.void
notifyListeners
(File file) Notify all listeners that files exist and need to be processed.void
removeFileListener
(FileListenerInterface listener) void
setErrorDirectory
(File errorDirectory) void
setPollCarefully
(boolean pollCarefully) void
setPollInterval
(long pollInterval) void
setStorageDirectory
(File storageDirectory) void
start()
Start polling in a background thread.void
stop()
Stop any currently scheduled polling.Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName, shutdown, startup
-
Field Details
-
POLL_CAREFULLY_PROPERTY
Property for pollCarefully- See Also:
-
DEFAULT_POLL_CAREFULLY
Default status of POLL_CAREFULLY- See Also:
-
POLL_DIRECTORY_PROPERTY
Property for pollDirectory- See Also:
-
DEFAULT_POLL_DIRECTORY
Default pollDirectory- See Also:
-
ERROR_DIRECTORY_PROPERTY
Property for errorDirectory- See Also:
-
DEFAULT_ERROR_DIRECTORY
Default errorDirectory- See Also:
-
STORAGE_DIRECTORY_PROPERTY
Property for storageDirectory- See Also:
-
DEFAULT_STORAGE_DIRECTORY
Default storageDirectory- See Also:
-
POLLINTERVAL_PROPERTY
Poll interval property- See Also:
-
DEFAULT_POLLINTERVAL
Default interval for POLLINTERVAL- See Also:
-
-
Constructor Details
-
DirectoryPoller
public DirectoryPoller()Create a DirectoryPoller.
-
-
Method Details
-
configure
Description copied from class:DefaultConfigurable
Process configuration settings. Called before startup().- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultConfigurable
- Parameters:
config
- the Config object with settings.- Throws:
Exception
- if configuration exceptions occur.
-
addFileListener
- Specified by:
addFileListener
in interfacePoller
- Parameters:
listener
- FileListenerInterface to add
-
removeFileListener
- Specified by:
removeFileListener
in interfacePoller
- Parameters:
listener
- FileListenerInterface to remove
-
notifyListeners
Notify all listeners that files exist and need to be processed.- Specified by:
notifyListeners
in interfacePoller
- Parameters:
file
- that needs to be processed
-
start
public void start()Start polling in a background thread. Any previously scheduled polling is stopped before starting at this frequency. This schedules using fixed-delay (time between complete polls) as opposed to fixed-rate (how often to start polling). -
stop
public void stop()Stop any currently scheduled polling. -
getPollDirectory
- Returns:
- pollDirectory file
-
getStorageDirectory
- Returns:
- storageDirectory file
-
setStorageDirectory
-
getErrorDirectory
- Returns:
- errorDirectory
-
setErrorDirectory
- Parameters:
errorDirectory
- File to send
-
getPollInterval
- Returns:
- pollInterval long
-
setPollInterval
public void setPollInterval(long pollInterval) - Parameters:
pollInterval
- long to set
-
isPollCarefully
- Returns:
- pollCarefully boolean
-
setPollCarefully
public void setPollCarefully(boolean pollCarefully) - Parameters:
pollCarefully
- boolean to set
-