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 StringDefault errorDirectorystatic final StringDefault status of POLL_CAREFULLYstatic final StringDefault pollDirectorystatic final StringDefault interval for POLLINTERVALstatic final StringDefault storageDirectorystatic final StringProperty for errorDirectorystatic final StringProperty for pollCarefullystatic final StringProperty for pollDirectorystatic final StringPoll interval propertystatic final StringProperty for storageDirectory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFileListener(FileListenerInterface listener) voidProcess configuration settings.voidnotifyListeners(File file) Notify all listeners that files exist and need to be processed.voidremoveFileListener(FileListenerInterface listener) voidsetErrorDirectory(File errorDirectory) voidsetPollCarefully(boolean pollCarefully) voidsetPollInterval(long pollInterval) voidsetStorageDirectory(File storageDirectory) voidstart()Start polling in a background thread.voidstop()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:DefaultConfigurableProcess configuration settings. Called before startup().- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classDefaultConfigurable- Parameters:
config- the Config object with settings.- Throws:
Exception- if configuration exceptions occur.
-
addFileListener
- Specified by:
addFileListenerin interfacePoller- Parameters:
listener- FileListenerInterface to add
-
removeFileListener
- Specified by:
removeFileListenerin interfacePoller- Parameters:
listener- FileListenerInterface to remove
-
notifyListeners
Notify all listeners that files exist and need to be processed.- Specified by:
notifyListenersin 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
-