Package adams.flow.standalone
Class SubProcessEvent
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,Pausable
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,VariableChangeListener
,Actor
,ActorHandler
,DaemonEvent
,ErrorHandler
,Event
,Flushable
,MutableActorHandler
,Serializable
,Comparable
public class SubProcessEvent extends AbstractStandalone implements MutableActorHandler, DaemonEvent, Pausable
Executes its sub-flow after a predefined number of milli-seconds.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING min-user-mode: Expert
-name <java.lang.String> (property: name) The name of the actor. default: SubProcessEvent
-annotation <adams.core.base.BaseAnnotation> (property: annotations) The annotations to attach to this actor. default:
-skip <boolean> (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is. default: false
-stop-flow-on-error <boolean> (property: stopFlowOnError) If set to true, the flow execution at this level gets stopped in case this actor encounters an error; the error gets propagated; useful for critical actors. default: false min-user-mode: Expert
-silent <boolean> (property: silent) If enabled, then no errors are output in the console; Note: the enclosing actor handler must have this enabled as well. default: false min-user-mode: Expert
-event-trigger <adams.flow.standalone.subprocessevent.SubProcessEventTrigger> (property: eventTrigger) The event trigger to reveive data from, process it and send back via. default: adams.flow.standalone.subprocessevent.Null
-actor <adams.flow.core.Actor> [-actor ...] (property: actors) The actor to use for processing the data. default: adams.flow.transformer.PassThrough
-scope-handling-variables <EMPTY|COPY|SHARE> (property: scopeHandlingVariables) Defines how variables are handled in the local scope; whether to start with empty set, a copy of the outer scope variables or share variables with the outer scope. default: EMPTY
-scope-handling-storage <EMPTY|COPY|SHARE> (property: scopeHandlingStorage) Defines how storage is handled in the local scope; whether to start with empty set, a (deep) copy of the outer scope storage or share the storage with the outer scope. default: EMPTY
-finish-before-stopping <boolean> (property: finishBeforeStopping) If enabled, actor first finishes processing all data before stopping. default: false
-stopping-timeout <int> (property: stoppingTimeout) The timeout in milliseconds when waiting for actors to finish (<= 0 for infinity; see 'finishBeforeStopping'). default: -1 minimum: -1
-stopping-warning-interval <int> (property: stoppingWarningInterval) The interval in milliseconds to output logging warnings if the actors haven't stopped yet (and no stopping timeout set); no warning if <= 0. default: 10000 minimum: -1
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected LocalScopeSubProcess
m_Actors
for actors that get executed.protected boolean
m_Busy
whether data is currently being processed.protected SubProcessEventTrigger
m_EventTrigger
the trigger.-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description SubProcessEvent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
active()
Returns the number of non-skipped actors.String
actorsTipText()
Returns the tip text for this property.String
add(int index, Actor actor)
Inserts the actor at the given position.String
add(Actor actor)
Inserts the actor at the end.String
check()
Performs checks on the "sub-actors".protected String
checkActors(Actor[] actors)
Checks the cron actors before they are set via the setActors method.void
cleanUp()
Cleans up after the execution has finished.void
defineOptions()
Adds options to the internal list of options.protected String
doExecute()
Executes the flow item.protected Object
doProcess(Object data, MessageCollection errors)
Processes the data with the sub-flow.String
eventTriggerTipText()
Returns the tip text for this property.String
finishBeforeStoppingTipText()
Returns the tip text for this property.Actor
firstActive()
Returns the first non-skipped actor.void
flushExecution()
Stops the processing of tokens without stopping the flow.protected void
forceVariables(Variables value)
Updates the Variables instance in use.Actor
get(int index)
Returns the actor at the given position.ActorHandlerInfo
getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.Actor[]
getActors()
Returns the actors for processing the data.SubProcessEventTrigger
getEventTrigger()
Returns the event trigger in use.boolean
getFinishBeforeStopping()
Returns whether to finish processing before stopping execution.protected LocalScopeSubProcess
getInternalActors()
Returns the internal representation of the actors.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.ScopeHandler.ScopeHandling
getScopeHandlingStorage()
Returns how storage is handled in the local scope.ScopeHandler.ScopeHandling
getScopeHandlingVariables()
Returns how variables are handled in the local scope.int
getStoppingTimeout()
Returns the timeout for waiting for the sub-flow to stop.int
getStoppingWarningInterval()
Returns the interval for outputting warnings if the sub-flow hasn't stopped yet (and no stopping timeout set).String
globalInfo()
Returns a string describing the object.int
indexOf(String actor)
Returns the index of the actor.protected void
initialize()
Initializes the members.boolean
isBusy()
Checks whether data is currently being processed.boolean
isPaused()
Returns whether the object is currently paused.Actor
lastActive()
Returns the last non-skipped actor.void
pauseExecution()
Pauses the execution.Object
process(Object data, MessageCollection errors)
Processes the data with the sub-flow.Actor
remove(int index)
Removes the actor at the given position and returns the removed object.void
removeAll()
Removes all actors.void
resumeExecution()
Resumes the execution.String
scopeHandlingStorageTipText()
Returns the tip text for this property.String
scopeHandlingVariablesTipText()
Returns the tip text for this property.String
set(int index, Actor actor)
Sets the actor at the given position.void
setActors(Actor[] value)
Sets the actors for processing the data.void
setEventTrigger(SubProcessEventTrigger value)
Sets the even trigger to use.void
setFinishBeforeStopping(boolean value)
Sets whether to finish processing before stopping execution.void
setLoggingLevel(LoggingLevel value)
Sets the logging level.void
setScopeHandlingStorage(ScopeHandler.ScopeHandling value)
Sets how to handle storage in the local scope.void
setScopeHandlingVariables(ScopeHandler.ScopeHandling value)
Sets how to handle variables into the local scope.void
setStoppingTimeout(int value)
Sets the timeout for waiting for the sub-flow to stop.void
setStoppingWarningInterval(int value)
Sets the interval for outputting warnings if the sub-flow hasn't stopped yet (and no stopping timeout set).String
setUp()
Initializes the sub-actors for flow execution.int
size()
Returns the size of the group.void
stopExecution()
Stops the execution.String
stoppingTimeoutTipText()
Returns the tip text for this property.String
stoppingWarningIntervalTipText()
Returns the tip text for this property.protected void
updateParent()
Updates the parent of all actors in this group.void
wrapUp()
Cleans up after the execution has finished.-
Methods inherited from class adams.flow.standalone.AbstractStandalone
preExecute
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canInspectOptions, canPerformSetUpCheck, compareTo, configureLogger, destroy, equals, execute, finalUpdateVariables, findVariables, findVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, pruneBackup, pruneBackup, reset, restoreState, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
m_EventTrigger
protected SubProcessEventTrigger m_EventTrigger
the trigger.
-
m_Actors
protected LocalScopeSubProcess m_Actors
for actors that get executed.
-
m_Busy
protected boolean m_Busy
whether data is currently being processed.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- 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 interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractActor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractActor
-
setEventTrigger
public void setEventTrigger(SubProcessEventTrigger value)
Sets the even trigger to use.- Parameters:
value
- the trigger
-
getEventTrigger
public SubProcessEventTrigger getEventTrigger()
Returns the event trigger in use.- Returns:
- the trigger
-
eventTriggerTipText
public String eventTriggerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setScopeHandlingVariables
public void setScopeHandlingVariables(ScopeHandler.ScopeHandling value)
Sets how to handle variables into the local scope.- Parameters:
value
- the scope handling
-
getScopeHandlingVariables
public ScopeHandler.ScopeHandling getScopeHandlingVariables()
Returns how variables are handled in the local scope.- Returns:
- the scope handling
-
scopeHandlingVariablesTipText
public String scopeHandlingVariablesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setScopeHandlingStorage
public void setScopeHandlingStorage(ScopeHandler.ScopeHandling value)
Sets how to handle storage in the local scope.- Parameters:
value
- the scope handling
-
getScopeHandlingStorage
public ScopeHandler.ScopeHandling getScopeHandlingStorage()
Returns how storage is handled in the local scope.- Returns:
- the scope handling
-
scopeHandlingStorageTipText
public String scopeHandlingStorageTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFinishBeforeStopping
public void setFinishBeforeStopping(boolean value)
Sets whether to finish processing before stopping execution.- Parameters:
value
- if true then actor finishes processing first
-
getFinishBeforeStopping
public boolean getFinishBeforeStopping()
Returns whether to finish processing before stopping execution.- Returns:
- true if actor finishes processing first
-
finishBeforeStoppingTipText
public String finishBeforeStoppingTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setStoppingTimeout
public void setStoppingTimeout(int value)
Sets the timeout for waiting for the sub-flow to stop.- Parameters:
value
- timeout in milliseconds (<= 0 for infinity)
-
getStoppingTimeout
public int getStoppingTimeout()
Returns the timeout for waiting for the sub-flow to stop.- Returns:
- timeout in milliseconds (<= 0 for infinity)
-
stoppingTimeoutTipText
public String stoppingTimeoutTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setStoppingWarningInterval
public void setStoppingWarningInterval(int value)
Sets the interval for outputting warnings if the sub-flow hasn't stopped yet (and no stopping timeout set).- Parameters:
value
- interval in milliseconds (<= 0 no warning)
-
getStoppingWarningInterval
public int getStoppingWarningInterval()
Returns the interval for outputting warnings if the sub-flow hasn't stopped yet (and no stopping timeout set).- Returns:
- interval in milliseconds (<= 0 no warning)
-
stoppingWarningIntervalTipText
public String stoppingWarningIntervalTipText()
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 interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractActor
- Returns:
- null if no info available, otherwise short string
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel value)
Sets the logging level.- Specified by:
setLoggingLevel
in interfaceLoggingLevelHandler
- Overrides:
setLoggingLevel
in classAbstractOptionHandler
- Parameters:
value
- the level
-
getInternalActors
protected LocalScopeSubProcess getInternalActors()
Returns the internal representation of the actors.- Returns:
- the actors
-
checkActors
protected String checkActors(Actor[] actors)
Checks the cron actors before they are set via the setActors method. Returns an error message if the actors are not acceptable, null otherwise.
Default implementation always returns null.- Parameters:
actors
- the actors to check- Returns:
- null if accepted, otherwise error message
-
updateParent
protected void updateParent()
Updates the parent of all actors in this group.
-
setActors
public void setActors(Actor[] value)
Sets the actors for processing the data.- Parameters:
value
- the actors
-
getActors
public Actor[] getActors()
Returns the actors for processing the data.- Returns:
- the actors
-
actorsTipText
public String actorsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
size
public int size()
Returns the size of the group.- Specified by:
size
in interfaceActorHandler
- Returns:
- always 1
-
get
public Actor get(int index)
Returns the actor at the given position.- Specified by:
get
in interfaceActorHandler
- Parameters:
index
- the position- Returns:
- the actor
-
set
public String set(int index, Actor actor)
Sets the actor at the given position.- Specified by:
set
in interfaceActorHandler
- Parameters:
index
- the positionactor
- the actor to set at this position- Returns:
- null if successful, otherwise error message
-
indexOf
public int indexOf(String actor)
Returns the index of the actor.- Specified by:
indexOf
in interfaceActorHandler
- Parameters:
actor
- the name of the actor to look for- Returns:
- the index of -1 if not found
-
add
public String add(Actor actor)
Inserts the actor at the end.- Specified by:
add
in interfaceMutableActorHandler
- Parameters:
actor
- the actor to insert- Returns:
- null if successful, otherwise error message
-
add
public String add(int index, Actor actor)
Inserts the actor at the given position.- Specified by:
add
in interfaceMutableActorHandler
- Parameters:
index
- the positionactor
- the actor to insert- Returns:
- null if successful, otherwise error message
-
remove
public Actor remove(int index)
Removes the actor at the given position and returns the removed object.- Specified by:
remove
in interfaceMutableActorHandler
- Parameters:
index
- the position- Returns:
- the removed actor
-
removeAll
public void removeAll()
Removes all actors.- Specified by:
removeAll
in interfaceMutableActorHandler
-
getActorHandlerInfo
public ActorHandlerInfo getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.- Specified by:
getActorHandlerInfo
in interfaceActorHandler
- Returns:
- the info
-
active
public int active()
Returns the number of non-skipped actors.- Returns:
- the 'active' actors
-
firstActive
public Actor firstActive()
Returns the first non-skipped actor.- Specified by:
firstActive
in interfaceActorHandler
- Returns:
- the first 'active' actor, null if none available
-
lastActive
public Actor lastActive()
Returns the last non-skipped actor.- Specified by:
lastActive
in interfaceActorHandler
- Returns:
- the last 'active' actor, null if none available
-
check
public String check()
Performs checks on the "sub-actors".- Specified by:
check
in interfaceActorHandler
- Returns:
- null if everything OK, otherwise error message
-
forceVariables
protected void forceVariables(Variables value)
Updates the Variables instance in use.
Use with caution!- Overrides:
forceVariables
in classAbstractActor
- Parameters:
value
- the instance to use
-
setUp
public String setUp()
Initializes the sub-actors for flow execution.- Specified by:
setUp
in interfaceActor
- Overrides:
setUp
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecute
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
-
doProcess
protected Object doProcess(Object data, MessageCollection errors)
Processes the data with the sub-flow.- Parameters:
data
- the data to processerrors
- for collecting errors- Returns:
- the processed data, null if failed to process or no data generated
-
process
public Object process(Object data, MessageCollection errors)
Processes the data with the sub-flow.- Parameters:
data
- the data to processerrors
- for collecting errors- Returns:
- the processed data, null if failed to process or no data generated
-
isBusy
public boolean isBusy()
Checks whether data is currently being processed.- Returns:
- true if data is being processed
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecution
in interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecution
in interfacePausable
-
flushExecution
public void flushExecution()
Stops the processing of tokens without stopping the flow.- Specified by:
flushExecution
in interfaceActorHandler
- Specified by:
flushExecution
in interfaceFlushable
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceActor
- Specified by:
stopExecution
in interfaceStoppable
- Overrides:
stopExecution
in classAbstractActor
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished. Graphical output is left untouched.- Specified by:
wrapUp
in interfaceActor
- Overrides:
wrapUp
in classAbstractActor
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished. Also removes graphical components.- Specified by:
cleanUp
in interfaceActor
- Specified by:
cleanUp
in interfaceCleanUpHandler
- Overrides:
cleanUp
in classAbstractActor
-
-