Package adams.flow.control
Class AbstractControlActor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.core.AbstractActor
-
- adams.flow.control.AbstractControlActor
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,Pausable,QuickInfoSupporter,ShallowCopySupporter<Actor>,SizeOfHandler,Stoppable,StoppableWithFeedback,VariablesInspectionHandler,FlowPauseStateListener,VariableChangeListener,Actor,ActorHandler,ControlActor,ErrorHandler,Flushable,SubFlowWrapUp,Serializable,Comparable
- Direct Known Subclasses:
AbstractDirectedControlActor,AbstractMutableStandaloneGroupItem,AbstractTee,Branch,Events,JavaExec,LaunchTee,LaunchTrigger,LoadBalancer,LocalScopeSubProcess,TryCatch,UpdateProperties,WhileLoop
public abstract class AbstractControlActor extends AbstractActor implements ControlActor, ActorHandler, Pausable, FlowPauseStateListener, SubFlowWrapUp
Ancestor for all actors that control sub-actors in some way.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Compatibilitym_Compatibilitythe compatibility class in use.protected PauseStateManagerm_PauseStateManagerthe pause state manager.protected booleanm_SetUpSubActorswhether the sub-actors were set up.-
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 AbstractControlActor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intactive()Returns the number of non-skipped actors.booleancanInspectOptions(Class cls)Checks whether the class' options can be inspected.Stringcheck()Performs checks on the "sub-actors".voidcleanUp()Cleans up after the execution has finished.voiddestroy()Frees up memory in a "destructive" non-reversible way.ActorfirstActive()Returns the first non-skipped actor.ActorfirstInputConsumer()Returns the first non-skipped InputConsumer.voidflowPauseStateChanged(FlowPauseStateEvent e)Gets called when the pause state of the flow changes.voidflushExecution()Stops the processing of tokens without stopping the flow.protected voidforceVariables(Variables value)Updates the Variables instance in use.abstract Actorget(int index)Returns the actor at the given position.abstract ActorHandlerInfogetActorHandlerInfo()Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.abstract intindexOf(String actor)Returns the index of the actor.protected voidinitialize()Initializes the members.booleanisPaused()Returns whether the object is currently paused.booleanisSubFlowWrappedUp()Checks whether the sub-flow has been wrapped up.ActorlastActive()Returns the last non-skipped actor.voidpauseExecution()Pauses the execution.protected StringpreExecute()Pre-execute hook.protected voidreset()Resets the actor.voidresumeExecution()Resumes the execution.abstract Stringset(int index, Actor actor)Sets the actor at the given position.voidsetParent(Actor value)Sets the parent of this actor, e.g., the group it belongs to.StringsetUp()Initializes the sub-actors for flow execution.protected StringsetUpSubActors()Performs the setUp of the sub-actors.abstract intsize()Returns the size of the group.voidstopExecution()Stops the execution.protected voidupdateParent()Updates the parent of all actors in this group.voidwrapUp()Finishes up the execution.voidwrapUpSubFlow()Wraps up the sub-actors, freeing up memory.-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canPerformSetUpCheck, compareTo, configureLogger, defineOptions, doExecute, equals, execute, finalUpdateVariables, findVariables, findVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getQuickInfo, 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, restoreState, setAnnotations, setErrorHandler, setName, 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, globalInfo, loggingLevelTipText, newOptionManager, setLoggingLevel, 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, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getQuickInfo, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, 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, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, defineOptions, getOptionManager
-
-
-
-
Field Detail
-
m_Compatibility
protected Compatibility m_Compatibility
the compatibility class in use.
-
m_PauseStateManager
protected PauseStateManager m_PauseStateManager
the pause state manager.
-
m_SetUpSubActors
protected boolean m_SetUpSubActors
whether the sub-actors were set up.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractActor
-
reset
protected void reset()
Resets the actor.- Overrides:
resetin classAbstractActor
-
setParent
public void setParent(Actor value)
Sets the parent of this actor, e.g., the group it belongs to.- Specified by:
setParentin interfaceActor- Overrides:
setParentin classAbstractActor- Parameters:
value- the new parent
-
forceVariables
protected void forceVariables(Variables value)
Updates the Variables instance in use.
Use with caution!- Overrides:
forceVariablesin classAbstractActor- Parameters:
value- the instance to use
-
getActorHandlerInfo
public abstract ActorHandlerInfo getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.- Specified by:
getActorHandlerInfoin interfaceActorHandler- Returns:
- the info
-
size
public abstract int size()
Returns the size of the group.- Specified by:
sizein interfaceActorHandler- Returns:
- the size
-
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:
firstActivein interfaceActorHandler- Returns:
- the first 'active' actor, null if none available
-
lastActive
public Actor lastActive()
Returns the last non-skipped actor.- Specified by:
lastActivein interfaceActorHandler- Returns:
- the last 'active' actor, null if none available
-
firstInputConsumer
public Actor firstInputConsumer()
Returns the first non-skipped InputConsumer.- Returns:
- the first 'active' InputConsumer, null if none available
-
get
public abstract Actor get(int index)
Returns the actor at the given position.- Specified by:
getin interfaceActorHandler- Parameters:
index- the position- Returns:
- the actor
-
set
public abstract String set(int index, Actor actor)
Sets the actor at the given position.- Specified by:
setin interfaceActorHandler- Parameters:
index- the positionactor- the actor to set at this position- Returns:
- null if successful, otherwise error message
-
indexOf
public abstract int indexOf(String actor)
Returns the index of the actor.- Specified by:
indexOfin interfaceActorHandler- Parameters:
actor- the name of the actor to look for- Returns:
- the index of -1 if not found
-
updateParent
protected void updateParent()
Updates the parent of all actors in this group.
-
canInspectOptions
public boolean canInspectOptions(Class cls)
Checks whether the class' options can be inspected. By default, arrays of actors (i.e., the control actor's sub-actors) won't be inspected, as they do it themselves.- Specified by:
canInspectOptionsin interfaceVariablesInspectionHandler- Overrides:
canInspectOptionsin classAbstractActor- Parameters:
cls- the class to check- Returns:
- true if it can be inspected, false otherwise
-
setUpSubActors
protected String setUpSubActors()
Performs the setUp of the sub-actors.- Returns:
- null if everything is fine, otherwise error message
-
setUp
public String setUp()
Initializes the sub-actors for flow execution.- Specified by:
setUpin interfaceActor- Overrides:
setUpin classAbstractActor- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
check
public String check()
Performs checks on the "sub-actors". Default implementation does nothing.- Specified by:
checkin interfaceActorHandler- Returns:
- null
-
preExecute
protected String preExecute()
Pre-execute hook.
Attempts to setUp actor again, if it was wrapped up before.- Overrides:
preExecutein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
- See Also:
SubFlowWrapUp.wrapUpSubFlow()
-
flushExecution
public void flushExecution()
Stops the processing of tokens without stopping the flow.- Specified by:
flushExecutionin interfaceActorHandler- Specified by:
flushExecutionin interfaceFlushable
-
wrapUp
public void wrapUp()
Finishes up the execution.- Specified by:
wrapUpin interfaceActor- Overrides:
wrapUpin classAbstractActor
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished. Also removes graphical components.- Specified by:
cleanUpin interfaceActor- Specified by:
cleanUpin interfaceCleanUpHandler- Overrides:
cleanUpin classAbstractActor
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Cleans up the options and calls the destroy() method of all sub-actors.- Specified by:
destroyin interfaceActor- Specified by:
destroyin interfaceDestroyable- Overrides:
destroyin classAbstractActor- See Also:
AbstractOptionHandler.cleanUpOptions()
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecutionin interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecutionin interfacePausable
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecutionin interfaceActor- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractActor
-
flowPauseStateChanged
public void flowPauseStateChanged(FlowPauseStateEvent e)
Gets called when the pause state of the flow changes.
Default implementation does nothing.- Specified by:
flowPauseStateChangedin interfaceFlowPauseStateListener- Parameters:
e- the event
-
wrapUpSubFlow
public void wrapUpSubFlow()
Wraps up the sub-actors, freeing up memory.- Specified by:
wrapUpSubFlowin interfaceSubFlowWrapUp
-
isSubFlowWrappedUp
public boolean isSubFlowWrappedUp()
Checks whether the sub-flow has been wrapped up.- Specified by:
isSubFlowWrappedUpin interfaceSubFlowWrapUp- Returns:
- true if sub-flow was wrapped up
-
-