Class FileEventActivityHandler
- java.lang.Object
-
- de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandler
-
- de.aristaflow.adept2.core.eventmanager.common.AbstractActivityEventHandler
-
- de.aristaflow.adept2.core.eventmanager.fileevents.FileEventActivityHandler
-
- All Implemented Interfaces:
ActivityEventHandler
,EventHandler
@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 FileEventActivityHandler extends AbstractActivityEventHandler
An event handler for file events, that stores data from an occurred file event as output parameter in the data context of the corresponding activity.
This event handler considers a handled file event as consumed since the corresponding activity has been terminated.This implementation is robust with respect to invalid parameter configurations and conversions, that is a parameter configuration referring to an unknown field of the file is just logged. The activity will be terminated normally but in case of a mandatory output parameter this will fail the activity.
-
-
Field Summary
Fields Modifier and Type Field Description static 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.static long
HANDLER_FILE_IO_EXCEPTION_CODE
Code for creating UDT values based on the file fails.static String
HANDLER_FILE_IO_EXCEPTION_STATE
State for creating UDT values based on the file fails.static String
PARAM_AC_PREFIX
Prefix for our configuration values in the parameter's activity configuration.static String
PARAM_FILE
Process parameter name for the file.static String
PARAM_FILENAME
Process parameter name for the file name.static String
PARAM_MODIFIED_DATE
Process parameter name for the file name.-
Fields inherited from class de.aristaflow.adept2.core.eventmanager.common.AbstractActivityEventHandler
contexts, eventManager
-
Fields inherited from class de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandler
consuming, critical, exclusive, id, interruptible, logger
-
-
Constructor Summary
Constructors Constructor Description FileEventActivityHandler(org.apache.commons.configuration2.Configuration conf, ActivityEventManager eventManager, Registry registry)
Creates a new handler for file events that starts or resumes activities and stores data from the file in their output data context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canHandle(Event event, boolean consumed)
Gets whether the designated event can be handled by this (sub-)class.protected boolean
processEvent(Event event, ActivityInstance activity, DataContext dataContext)
Processes the designated event for the designated activity instance.-
Methods inherited from class de.aristaflow.adept2.core.eventmanager.common.AbstractActivityEventHandler
close, handleEvent, init, kill, remove, reset, signal, suspend
-
Methods inherited from class de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandler
getID, isConsuming, isCritical, isExclusive, isInterruptible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.aristaflow.adept2.model.events.handler.EventHandler
getID, isConsuming, isExclusive, isInterruptible
-
-
-
-
Field Detail
-
CONF_IS_CRITICAL
public 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
-
HANDLER_FILE_IO_EXCEPTION_STATE
public static final String HANDLER_FILE_IO_EXCEPTION_STATE
State for creating UDT values based on the file fails.- See Also:
- Constant Field Values
-
HANDLER_FILE_IO_EXCEPTION_CODE
public static final long HANDLER_FILE_IO_EXCEPTION_CODE
Code for creating UDT values based on the file fails.- See Also:
- Constant Field Values
-
PARAM_AC_PREFIX
public static final String PARAM_AC_PREFIX
Prefix for our configuration values in the parameter's activity configuration.- See Also:
- Constant Field Values
-
PARAM_FILENAME
public static final String PARAM_FILENAME
Process parameter name for the file name.- See Also:
- Constant Field Values
-
PARAM_MODIFIED_DATE
public static final String PARAM_MODIFIED_DATE
Process parameter name for the file name.- See Also:
- Constant Field Values
-
PARAM_FILE
public static final String PARAM_FILE
Process parameter name for the file.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileEventActivityHandler
public FileEventActivityHandler(org.apache.commons.configuration2.Configuration conf, ActivityEventManager eventManager, Registry registry)
Creates a new handler for file events that starts or resumes activities and stores data from the file in their output data context.- Parameters:
conf
- The configuration for this plugin instance.eventManager
- The event manager for communicating with the runtime service.registry
- The registry for retrieving the plugin instance name (handler ID).
-
-
Method Detail
-
canHandle
protected boolean canHandle(Event event, boolean consumed)
Description copied from class:AbstractActivityEventHandler
Gets whether the designated event can be handled by this (sub-)class. This should for instance check for the event type as well as whether consumed events can be handled.- Specified by:
canHandle
in classAbstractActivityEventHandler
- Parameters:
event
- The event which is about to be handled.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
).
-
processEvent
protected boolean processEvent(Event event, ActivityInstance activity, DataContext dataContext)
Description copied from class:AbstractActivityEventHandler
Processes the designated event for the designated activity instance. Usually this requires setting the output parameters in the designated data context appropriately based on the event.- Specified by:
processEvent
in classAbstractActivityEventHandler
- Parameters:
event
- The event to be processed.activity
- The activity for which to process event. This also provides the configuration of the activity and also the defined output parameters.dataContext
- The data context to write the values of the output parameters to.- 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:
ApplicationFailedException
- If- one of the designated parameter has an inappropriate type with respect to the data context or its user-defined type is not valid for the corresponding field,
- one of the designated parameter does not exist in the data context,
- there are problems serialising fields of the message or retrieving content, or
- there are problems serialising fields of the file
ApplicationFailedException
will be thrown.
-
-