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.
This handler considers a changed file as consumed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanWhether to add a lock file for files from file events.static final StringConfiguration key for whether to add lock files for files from file events.static final StringConfiguration key for whether to delete files from file events.static final StringConfiguration key for whether this handler should also handle files of which the corresponding file event has been consumed.static final StringConfiguration key: Whether the event handler is critical and problems handling the event should abort all handling of the current event.static final StringConfiguration key for whether to mark the lock file or the data file.static final StringConfiguration key for whether to move files from file events.static final StringConfiguration key for whether to rename files from file events.static final StringConfiguration key for whether to replace an existing target file or a file in the target folder.static final StringConfiguration key for the name of the target folder in case the files of file events should be moved.static final StringConfiguration key for how to set the new name for files from file events.protected final booleanWhether to delete the files from file events.protected final booleanWhether this handler should also handle files of which the corresponding file event has been consumed.protected final booleanWhether the original file or the lock file should be marked.protected final StringThe mark options represented as string.protected final booleanWhether to move the files from file events.protected final booleanWhether to rename the files from file events.protected final booleanWhether to replace an existing target file or a file in the target folder.protected final StringThe name of the target folder in case the files from file events should be moved.protected final StringThe 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.AbstractEventHandler
consuming, critical, exclusive, id, interruptible, logger -
Constructor Summary
ConstructorsConstructorDescriptionFileMarkHandler(Configuration conf, AbstractEventManager eventManager, Registry registry) Default constructor for a plugin of anEventManagercalled by a service registry.FileMarkHandler(Configuration conf, EventManager eventManager, Registry registry) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhandleEvent(Event eve, boolean consumed) This method actually processes an event.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.AbstractEventHandler
getID, isConsuming, isCritical, isExclusive, isInterruptible
-
Field Details
-
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:
-
CONF_HANDLE_CONSUMED
Configuration key for whether this handler should also handle files of which the corresponding file event has been consumed.- See Also:
-
HANDLE_CONSUMED
protected final boolean HANDLE_CONSUMEDWhether this handler should also handle files of which the corresponding file event has been consumed. -
CONF_DELETE_FILE
Configuration key for whether to delete files from file events.- See Also:
-
DELETE_FILE
protected final boolean DELETE_FILEWhether to delete the files from file events. -
CONF_RENAME_FILE
Configuration key for whether to rename files from file events.- See Also:
-
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:
-
RENAME_FILE
protected final boolean RENAME_FILEWhether to rename the files from file events. -
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_FILE
Configuration key for whether to add lock files for files from file events.- See Also:
-
ADD_FILE
protected final boolean ADD_FILEWhether to add a lock file for files from file events. -
CONF_MOVE_FILE
Configuration key for whether to move files from file events.- See Also:
-
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:
-
MOVE_FILE
protected final boolean MOVE_FILEWhether to move the files from file events. -
TARGET_FOLDER
The name of the target folder in case the files from file events should be moved. -
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:
-
REPLACE_EXISTING
protected final boolean REPLACE_EXISTINGWhether to replace an existing target file or a file in the target folder. This applies to renaming and moving. -
CONF_MARK_LOCK_FILE
Configuration key for whether to mark the lock file or the data file.- See Also:
-
MARK_LOCK_FILE
protected final boolean MARK_LOCK_FILEWhether the original file or the lock file should be marked. -
markOptions
The mark options represented as string.
-
-
Constructor Details
-
FileMarkHandler
@Deprecated(since="16.2.0", forRemoval=true) public FileMarkHandler(Configuration conf, EventManager eventManager, Registry registry) throws ConfigurationException Deprecated, for removal: This API element is subject to removal in a future version.Default 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 aConfigurationExceptionwill be thrown.
-
FileMarkHandler
public FileMarkHandler(Configuration conf, AbstractEventManager eventManager, Registry registry) throws ConfigurationException Default 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 aConfigurationExceptionwill be thrown.
-
-
Method Details
-
handleEvent
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, anEventHandlingExceptionmay 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.
-
markFile
protected Triple<Boolean,File, markFileBoolean> (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, anEventHandlingExceptionmay be thrown.
-
FileMarkHandler(Configuration, AbstractEventManager, Registry)instead.