Class FileMarkHandler
- java.lang.Object
- 
- de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandler
- 
- de.aristaflow.adept2.core.eventmanager.fileevents.FileMarkHandler
 
 
- 
- All Implemented Interfaces:
- EventHandler
 - Direct Known Subclasses:
- MarkInstanceStartEventHandler
 
 @ConfigurationDescription(properties={@Property(name="IsCritical",type=BOOLEAN,defaultValue="true",description="Whether the event handler is critical and problems handling the event should abort all handling of the current event."),,,,,,,,,}) public class FileMarkHandler extends AbstractEventHandler An event handler for marking files from file events. This allows deletion, renaming or moving handled files so that they do not get handled again.
 This handler considers a changed file as consumed.
- 
- 
Field SummaryFields Modifier and Type Field Description protected booleanADD_FILEWhether to add a lock file for files from file events.static StringCONF_ADD_FILEConfiguration key for whether to add lock files for files from file events.static StringCONF_DELETE_FILEConfiguration key for whether to delete files from file events.static StringCONF_HANDLE_CONSUMEDConfiguration key for whether this handler should also handle files of which the corresponding file event has been consumed.static StringCONF_IS_CRITICALConfiguration key: Whether the event handler is critical and problems handling the event should abort all handling of the current event.static StringCONF_MARK_LOCK_FILEConfiguration key for whether to mark the lock file or the data file.static StringCONF_MOVE_FILEConfiguration key for whether to move files from file events.static StringCONF_RENAME_FILEConfiguration key for whether to rename files from file events.static StringCONF_REPLACE_EXISTINGConfiguration key for whether to replace an existing target file or a file in the target folder.static StringCONF_TARGET_FOLDERConfiguration key for the name of the target folder in case the files of file events should be moved.static StringCONF_TARGET_NAMEConfiguration key for how to set the new name for files from file events.protected booleanDELETE_FILEWhether to delete the files from file events.protected booleanHANDLE_CONSUMEDWhether this handler should also handle files of which the corresponding file event has been consumed.protected booleanMARK_LOCK_FILEWhether the original file or the lock file should be marked.protected booleanMOVE_FILEWhether to move the files from file events.protected booleanRENAME_FILEWhether to rename the files from file events.protected booleanREPLACE_EXISTINGWhether to replace an existing target file or a file in the target folder.protected StringTARGET_FOLDERThe name of the target folder in case the files from file events should be moved.protected StringTARGET_NAMEThe name or the pattern of the name the file should be renamed to or the names of the lock files.- 
Fields inherited from class de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandlerconsuming, critical, exclusive, id, interruptible, logger
 
- 
 - 
Constructor SummaryConstructors Constructor Description FileMarkHandler(org.apache.commons.configuration2.Configuration conf, EventManager eventManager, Registry registry)Default constructor for a plugin of anEventManagercalled by a service registry.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhandleEvent(Event eve, boolean consumed)This method actually processes an event.protected Triple<Boolean,File,Boolean>markFile(FileEvent eve, boolean consumed)Extracted fromhandleEvent(Event, boolean)so that it could be extended with the destination file, i.e.- 
Methods inherited from class de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandlergetID, isConsuming, isCritical, isExclusive, isInterruptible
 
- 
 
- 
- 
- 
Field Detail- 
CONF_IS_CRITICALpublic static final String CONF_IS_CRITICAL Configuration key: Whether the event handler is critical and problems handling the event should abort all handling of the current event.- See Also:
- Constant Field Values
 
 - 
CONF_HANDLE_CONSUMEDpublic static final String CONF_HANDLE_CONSUMED Configuration key for whether this handler should also handle files of which the corresponding file event has been consumed.- See Also:
- Constant Field Values
 
 - 
HANDLE_CONSUMEDprotected final boolean HANDLE_CONSUMED Whether this handler should also handle files of which the corresponding file event has been consumed.
 - 
CONF_DELETE_FILEpublic static final String CONF_DELETE_FILE Configuration key for whether to delete files from file events.- See Also:
- Constant Field Values
 
 - 
DELETE_FILEprotected final boolean DELETE_FILE Whether to delete the files from file events.
 - 
CONF_RENAME_FILEpublic static final String CONF_RENAME_FILE Configuration key for whether to rename files from file events.- See Also:
- Constant Field Values
 
 - 
CONF_TARGET_NAMEpublic static final String CONF_TARGET_NAME Configuration key for how to set the new name for files from file events. This will only apply if the file should be renamed.- See Also:
- Constant Field Values
 
 - 
RENAME_FILEprotected final boolean RENAME_FILE Whether to rename the files from file events.
 - 
TARGET_NAMEprotected final String TARGET_NAME The name or the pattern of the name the file should be renamed to or the names of the lock files. A '*' wildcard which will be replaced by the current file name.
 - 
CONF_ADD_FILEpublic static final String CONF_ADD_FILE Configuration key for whether to add lock files for files from file events.- See Also:
- Constant Field Values
 
 - 
ADD_FILEprotected final boolean ADD_FILE Whether to add a lock file for files from file events.
 - 
CONF_MOVE_FILEpublic static final String CONF_MOVE_FILE Configuration key for whether to move files from file events.- See Also:
- Constant Field Values
 
 - 
CONF_TARGET_FOLDERpublic static final String CONF_TARGET_FOLDER Configuration key for the name of the target folder in case the files of file events should be moved. This will only apply if the files from file events should be moved.- See Also:
- Constant Field Values
 
 - 
MOVE_FILEprotected final boolean MOVE_FILE Whether to move the files from file events.
 - 
TARGET_FOLDERprotected final String TARGET_FOLDER The name of the target folder in case the files from file events should be moved.
 - 
CONF_REPLACE_EXISTINGpublic static final String CONF_REPLACE_EXISTING Configuration key for whether to replace an existing target file or a file in the target folder. This applies to renaming and moving.- See Also:
- Constant Field Values
 
 - 
REPLACE_EXISTINGprotected final boolean REPLACE_EXISTING Whether to replace an existing target file or a file in the target folder. This applies to renaming and moving.
 - 
CONF_MARK_LOCK_FILEpublic static final String CONF_MARK_LOCK_FILE Configuration key for whether to mark the lock file or the data file.- See Also:
- Constant Field Values
 
 - 
MARK_LOCK_FILEprotected final boolean MARK_LOCK_FILE Whether the original file or the lock file should be marked.
 
- 
 - 
Constructor Detail- 
FileMarkHandlerpublic FileMarkHandler(org.apache.commons.configuration2.Configuration conf, EventManager eventManager, Registry registry) throws ConfigurationExceptionDefault constructor for a plugin of anEventManagercalled by a service registry. This constructor just reads the configuration values.- Parameters:
- conf- The configuration as provided from the registry.
- eventManager- The event manager this event handler is a plugin of.
- registry- The registry of this plugin.
- Throws:
- ConfigurationException- If there are problems with the configuration a- ConfigurationExceptionwill be thrown.
 
 
- 
 - 
Method Detail- 
handleEventpublic boolean handleEvent(Event eve, boolean consumed) throws EventHandlingException Description copied from interface:EventHandlerThis method actually processes an event. What is done depends on the implementation of the event handler. Some restrictions may apply depending on the produced event. Only events will be received for which the event handler is registered. However, to improve robustness, an event handler should check the event before processing. If it cannot handle the provided event, this method should just return.
 Event handling is usually synchronously, that is, this method will only be executed by one thread at a time. If another event of the same type occurs while still handling the previous event, the second event will be suspended until the previous event has been completely handled. There is no need to start a separate thread while handling to improve performance. But it is not forbidden to do so. Handling that takes place in a new thread is not exclusive any more and therefore must not consume the event!- Parameters:
- eve- The event that occurred and for which this event handler is registered.
- consumed- Whether the event has been consumed by a previous event handler.
- Returns:
- Whether the event has been consumed (that is changed) while
         handling it. If the event has been consumed before the current
         handing, it will have to remain consumed (implementations must
         return true).
- Throws:
- EventHandlingException- If there have been problems handling the event, an- EventHandlingExceptionmay be thrown. If this is critical, the event handling for the current event will stop. If it is non-critical, other event handlers will also get the event for handling it.
 If event handling fails, the corresponding event handler needs to roll back its changes, especially a consuming event handler.
 
 - 
markFileprotected Triple<Boolean,File,Boolean> markFile(FileEvent eve, boolean consumed) throws EventHandlingException Extracted fromhandleEvent(Event, boolean)so that it could be extended with the destination file, i.e. the file the source was renamed or moved to.- Parameters:
- eve- The event that occurred and for which this event handler is registered.
- consumed- Whether the event has been consumed by a previous event handler.
- Returns:
- Whether the event has been consumed (that is changed) while handling it plus the new
         file that was created/changed while handling (or nullfor a deleted file). This new file could be used as input parameter for the instance start event handler. The third element indicates whether the marked file is the lock file.
- Throws:
- EventHandlingException- If there have been problems handling the event, an- EventHandlingExceptionmay be thrown.
 
 
- 
 
-