Package adams.flow.standalone.rats.input
Class DirWatch
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.standalone.rats.input.AbstractRatInput
-
- adams.flow.standalone.rats.input.DirWatch
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler
,adams.core.AtomicMoveSupporter
,adams.core.CleanUpHandler
,adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.QuickInfoSupporter
,adams.core.ShallowCopySupporter<AbstractRatInput>
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.core.StoppableWithFeedback
,RatInput
,Serializable
public class DirWatch extends AbstractRatInput implements adams.core.AtomicMoveSupporter
Watches for file changes in a directory and forwards the affected files.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-source <adams.core.io.PlaceholderDirectory> (property: source) The directory to watch. default: ${CWD}
-event <CREATE|MODIFY|DELETE> [-event ...] (property: events) The kind of events to report. default: CREATE
-wait-poll <int> (property: waitPoll) The number of milli-seconds to wait before polling again whether files have arrived. default: 50 minimum: 0
-wait-list <int> (property: waitList) The number of milli-seconds to wait after listing the files. default: 0 minimum: 0
-move-files <boolean> (property: moveFiles) If enabled, the files get moved to the specified directory first before being transmitted (with their new filename). default: false
-atomic-move <boolean> (property: atomicMove) If true, then an atomic move operation will be attempted (NB: not supported by all operating systems). default: false
-target <adams.core.io.PlaceholderDirectory> (property: target) The directory to move the files to before transmitting their names. default: ${CWD}
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_AtomicMove
whether to perform an atomic move.protected adams.core.io.WatchEventKind[]
m_Events
the events to look for.protected List<String>
m_Files
the files that were picked up by the watch service.protected boolean
m_MoveFiles
whether to move the files before transmitting them.protected adams.core.base.BaseRegExp
m_RegExp
the regular expression to match the file names against.protected adams.core.io.PlaceholderDirectory
m_Source
the directory to watch.protected adams.core.io.PlaceholderDirectory
m_Target
the directory to move the files to.protected int
m_WaitPoll
the waiting period in msec before polling again.protected WatchService
m_Watch
the watch service.-
Fields inherited from class adams.flow.standalone.rats.input.AbstractRatInput
m_LoggingPrefix, m_Owner, m_ReceptionInterrupted, m_ReceptionRunning, m_Stopped
-
-
Constructor Summary
Constructors Constructor Description DirWatch()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
atomicMoveTipText()
Returns the tip text for this property.String
check()
Hook method for performing checks.void
defineOptions()
Adds options to the internal list of options.protected String
doReceive()
Performs the actual reception of data.String
eventsTipText()
Returns the tip text for this property.Class
generates()
Returns the type of data this scheme generates.boolean
getAtomicMove()
Returns whether to attempt atomic move operation.adams.core.io.WatchEventKind[]
getEvents()
Returns the events to report.boolean
getMoveFiles()
Returns whether to move the files to the specified target directory before transmitting them.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.adams.core.base.BaseRegExp
getRegExp()
Returns the regular expression to match the filenames against (name only, not path).adams.core.io.PlaceholderDirectory
getSource()
Returns the incoming directory.adams.core.io.PlaceholderDirectory
getTarget()
Returns the move-to directory.int
getWaitPoll()
Returns the number of milli-seconds to wait before polling again whether files have arrived.String
globalInfo()
Returns a string describing the object.boolean
hasPendingOutput()
Checks whether any output can be collected.protected void
initialize()
Initializes the members.String
moveFilesTipText()
Returns the tip text for this property.Object
output()
Returns the received data.String
regExpTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.void
setAtomicMove(boolean value)
Sets whether to attempt atomic move operation.void
setEvents(adams.core.io.WatchEventKind[] value)
Sets the events to report.void
setMoveFiles(boolean value)
Sets whether to move the files to the specified target directory before transmitting them.void
setRegExp(adams.core.base.BaseRegExp value)
Sets the regular expression to match the filenames against (name only, not path).void
setSource(adams.core.io.PlaceholderDirectory value)
Sets the incoming directory.void
setTarget(adams.core.io.PlaceholderDirectory value)
Sets the move-to directory.void
setWaitPoll(int value)
Sets the number of milli-seconds to wait before polling whether files have arrived.String
sourceTipText()
Returns the tip text for this property.void
stopExecution()
Stops the execution.protected void
stopWatchService()
Stops the watch service, if active.String
targetTipText()
Returns the tip text for this property.String
waitPollTipText()
Returns the tip text for this property.-
Methods inherited from class adams.flow.standalone.rats.input.AbstractRatInput
canReceive, cleanUp, configureLogger, doWait, getAdditionalInformation, getFullName, getOwner, getQueue, getReceptionInterrupted, handleException, initReception, interruptReception, isReceptionRunning, isStopped, receive, setOwner, setUp, shallowCopy, shallowCopy, updatePrefix
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Source
protected adams.core.io.PlaceholderDirectory m_Source
the directory to watch.
-
m_Events
protected adams.core.io.WatchEventKind[] m_Events
the events to look for.
-
m_WaitPoll
protected int m_WaitPoll
the waiting period in msec before polling again.
-
m_RegExp
protected adams.core.base.BaseRegExp m_RegExp
the regular expression to match the file names against.
-
m_MoveFiles
protected boolean m_MoveFiles
whether to move the files before transmitting them.
-
m_AtomicMove
protected boolean m_AtomicMove
whether to perform an atomic move.
-
m_Target
protected adams.core.io.PlaceholderDirectory m_Target
the directory to move the files to.
-
m_Watch
protected transient WatchService m_Watch
the watch service.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractRatInput
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classadams.core.option.AbstractOptionHandler
-
setSource
public void setSource(adams.core.io.PlaceholderDirectory value)
Sets the incoming directory.- Parameters:
value
- the incoming directory
-
getSource
public adams.core.io.PlaceholderDirectory getSource()
Returns the incoming directory.- Returns:
- the incoming directory.
-
sourceTipText
public String sourceTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setEvents
public void setEvents(adams.core.io.WatchEventKind[] value)
Sets the events to report.- Parameters:
value
- the events
-
getEvents
public adams.core.io.WatchEventKind[] getEvents()
Returns the events to report.- Returns:
- the events
-
eventsTipText
public String eventsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setWaitPoll
public void setWaitPoll(int value)
Sets the number of milli-seconds to wait before polling whether files have arrived.- Parameters:
value
- the number of milli-seconds
-
getWaitPoll
public int getWaitPoll()
Returns the number of milli-seconds to wait before polling again whether files have arrived.- Returns:
- the number of milli-seconds
-
waitPollTipText
public String waitPollTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setRegExp
public void setRegExp(adams.core.base.BaseRegExp value)
Sets the regular expression to match the filenames against (name only, not path).- Parameters:
value
- the expression
-
getRegExp
public adams.core.base.BaseRegExp getRegExp()
Returns the regular expression to match the filenames against (name only, not path).- Returns:
- the expression
-
regExpTipText
public String regExpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMoveFiles
public void setMoveFiles(boolean value)
Sets whether to move the files to the specified target directory before transmitting them.- Parameters:
value
- true if to move files
-
getMoveFiles
public boolean getMoveFiles()
Returns whether to move the files to the specified target directory before transmitting them.- Returns:
- true if to move files
-
moveFilesTipText
public String moveFilesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAtomicMove
public void setAtomicMove(boolean value)
Sets whether to attempt atomic move operation.- Specified by:
setAtomicMove
in interfaceadams.core.AtomicMoveSupporter
- Parameters:
value
- if true then attempt atomic move operation
-
getAtomicMove
public boolean getAtomicMove()
Returns whether to attempt atomic move operation.- Specified by:
getAtomicMove
in interfaceadams.core.AtomicMoveSupporter
- Returns:
- true if to attempt atomic move operation
-
atomicMoveTipText
public String atomicMoveTipText()
Returns the tip text for this property.- Specified by:
atomicMoveTipText
in interfaceadams.core.AtomicMoveSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTarget
public void setTarget(adams.core.io.PlaceholderDirectory value)
Sets the move-to directory.- Parameters:
value
- the move-to directory
-
getTarget
public adams.core.io.PlaceholderDirectory getTarget()
Returns the move-to directory.- Returns:
- the move-to directory.
-
targetTipText
public String targetTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceadams.core.QuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractRatInput
- Returns:
- null if no info available, otherwise short string
-
generates
public Class generates()
Returns the type of data this scheme generates.- Specified by:
generates
in interfaceRatInput
- Specified by:
generates
in classAbstractRatInput
- Returns:
- the type of data
-
check
public String check()
Hook method for performing checks. Makes sure that directories exist.- Overrides:
check
in classAbstractRatInput
- Returns:
- null if successful, otherwise error message
-
doReceive
protected String doReceive()
Performs the actual reception of data.- Specified by:
doReceive
in classAbstractRatInput
- Returns:
- null if successful, otherwise error message
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether any output can be collected.- Specified by:
hasPendingOutput
in interfaceRatInput
- Specified by:
hasPendingOutput
in classAbstractRatInput
- Returns:
- true if output available
-
output
public Object output()
Returns the received data.- Specified by:
output
in interfaceRatInput
- Specified by:
output
in classAbstractRatInput
- Returns:
- the data
-
stopWatchService
protected void stopWatchService()
Stops the watch service, if active.
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceRatInput
- Specified by:
stopExecution
in interfaceadams.core.Stoppable
- Overrides:
stopExecution
in classAbstractRatInput
-
-