Class MarkInstanceStartEventHandler
java.lang.Object
de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandler
de.aristaflow.adept2.core.eventmanager.fileevents.FileMarkHandler
de.aristaflow.adept2.core.eventmanager.fileevents.MarkInstanceStartEventHandler
- All Implemented Interfaces:
EventHandler
@ConfigurationDescription(properties=)
public class MarkInstanceStartEventHandler
extends FileMarkHandler
An event handler for file events, that marks the files (rename, move) and afterwards stores data
from an occurred file event as input parameters in the data container of an instance and starts
this instance afterwards. When marking the file via deletion, this will take place after starting
the instance. Make sure to provide the complete file to the process instance and not just a
reference (URI). This reference will be invalid after deleting the file! This does not apply to
renaming or moving since this takes place beforehand and therefore the reference will be for
after remaining or moving.
The input parameters need to have specific names to allow for setting the values according to the file.
This handler considers a changed file as consumed.
NOTE: This is a combination of
The input parameters need to have specific names to allow for setting the values according to the file.
This handler considers a changed file as consumed.
NOTE: This is a combination of
FileMarkHandler and
InstanceStartEventHandler.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.protected final AbstractEventManagerThe event manager for communicating with the runtime service.static final StringProcess parameter name for the file.static final StringProcess parameter name for the file name.static final StringProcess parameter name for the lock file.static final StringProcess parameter name for the file name.protected final StringThe process type of which to start the "latest" template in case the appropriate event occurs.protected TemplateReferenceThe template which to instantiate in case an appropriate mail event occurs.Fields inherited from class de.aristaflow.adept2.core.eventmanager.fileevents.FileMarkHandler
ADD_FILE, CONF_ADD_FILE, CONF_DELETE_FILE, CONF_HANDLE_CONSUMED, CONF_IS_CRITICAL, CONF_MARK_LOCK_FILE, CONF_MOVE_FILE, CONF_RENAME_FILE, CONF_REPLACE_EXISTING, CONF_TARGET_FOLDER, CONF_TARGET_NAME, DELETE_FILE, HANDLE_CONSUMED, MARK_LOCK_FILE, markOptions, MOVE_FILE, RENAME_FILE, REPLACE_EXISTING, TARGET_FOLDER, TARGET_NAMEFields inherited from class de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandler
consuming, critical, exclusive, id, interruptible, logger -
Constructor Summary
ConstructorsConstructorDescriptionMarkInstanceStartEventHandler(Configuration conf, AbstractEventManager eventManager, Registry registry) Creates a new handler for file events that starts instances and stores data from the file in the instance input parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected TemplateReferencegetAndCheckTemplate(SessionToken session) Retrieves the "latest" template of the configured process type and checks for whether it has the right input parameter.booleanhandleEvent(Event eve, boolean consumed) This method actually processes an event.protected voidprocessFileEvent(FileEvent event, Collection<? extends Parameter> inParams, InstanceDataContainer dataContainer, File file, File lockFile) Processes the file of the designated event and sets the values of the input parameters in the designated data container.Methods inherited from class de.aristaflow.adept2.core.eventmanager.fileevents.FileMarkHandler
markFileMethods inherited from class de.aristaflow.adept2.core.eventmanager.common.AbstractEventHandler
getID, isConsuming, isCritical, isExclusive, isInterruptible
-
Field Details
-
CONF_PROCESS_TYPE
Deprecated, for removal: This API element is subject to removal in a future version.UseAbstractInstanceStartEventHandler.CONF_PROCESS_TYPEinstead.Configuration key: The process type of which to start the "latest" template in case the appropriate event occurs.- See Also:
-
processType
The process type of which to start the "latest" template in case the appropriate event occurs. -
template
The template which to instantiate in case an appropriate mail event occurs. This will be temporarily set tonullif there are problems instantiating it. -
eventManager
The event manager for communicating with the runtime service. -
PARAM_FILENAME
Process parameter name for the file name.- See Also:
-
PARAM_MODIFIED_DATE
Process parameter name for the file name.- See Also:
-
PARAM_FILE
Process parameter name for the file.- See Also:
-
PARAM_LOCK_FILE
Process parameter name for the lock file.- See Also:
-
-
Constructor Details
-
MarkInstanceStartEventHandler
public MarkInstanceStartEventHandler(Configuration conf, AbstractEventManager eventManager, Registry registry) throws ConfigurationException Creates a new handler for file events that starts instances and stores data from the file in the instance input parameters.- Parameters:
conf- The configuration for this plugin instance.eventManager- The event manager for starting the process instance.registry- The registry for retrieving the plugin instance name (handler ID).- Throws:
ConfigurationException- If there are problems creating the configured file store or writing to it or the template cannot be retrieved or has the wrong input parameter, 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!- Specified by:
handleEventin interfaceEventHandler- Overrides:
handleEventin classFileMarkHandler- 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.
-
getAndCheckTemplate
protected TemplateReference getAndCheckTemplate(SessionToken session) throws de.aristaflow.adept2.core.eventmanager.fileevents.MarkInstanceStartEventHandler.TemplateLoadingException Retrieves the "latest" template of the configured process type and checks for whether it has the right input parameter. An input parameter having the right name for a file event must be of the right data type and there must not be any mandatory input parameter that do not have an appropriate file event name.- Parameters:
session- The session token used to retrieve the "latest" template.- Returns:
- The "latest" template of the configured process type or
nullin case the process type does not have a template. - Throws:
de.aristaflow.adept2.core.eventmanager.fileevents.MarkInstanceStartEventHandler.TemplateLoadingException- If the template has an input parameter mapping to a file event (due to its name) but has the wrong type or it has a mandatory input parameter that does not map to a file event, aTemplateLoadingExceptionwill be thrown.
-
processFileEvent
protected void processFileEvent(FileEvent event, Collection<? extends Parameter> inParams, InstanceDataContainer dataContainer, File file, File lockFile) throws InvalidDataTypeException, NoSuchParameterException, IOException Processes the file of the designated event and sets the values of the input parameters in the designated data container.- Parameters:
event- The event which to process and which provides the values for the input parameters.inParams- The input parameters of the template.dataContainer- The data container of the template in which to set the values.- Throws:
InvalidDataTypeException- If writing to the data container fails due to a provided input parameter having another type in the data container or a parameter has a wrong user-defined type, anInvalidDataTypeExceptionwill be thrown.NoSuchParameterException- If writing to the data container fails due to a provided input parameter not being in the data container, aNoSuchParameterExceptionwill be thrown.IOException- If creating the value for an UDT fails, anIOExceptionwill be thrown.
-
AbstractInstanceStartEventHandler.CONF_PROCESS_TYPEinstead.