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 Compatibility
m_Compatibility
the compatibility class in use.protected PauseStateManager
m_PauseStateManager
the pause state manager.protected boolean
m_SetUpSubActors
whether 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 int
active()
Returns the number of non-skipped actors.boolean
canInspectOptions(Class cls)
Checks whether the class' options can be inspected.String
check()
Performs checks on the "sub-actors".void
cleanUp()
Cleans up after the execution has finished.void
destroy()
Frees up memory in a "destructive" non-reversible way.Actor
firstActive()
Returns the first non-skipped actor.Actor
firstInputConsumer()
Returns the first non-skipped InputConsumer.void
flowPauseStateChanged(FlowPauseStateEvent e)
Gets called when the pause state of the flow changes.void
flushExecution()
Stops the processing of tokens without stopping the flow.protected void
forceVariables(Variables value)
Updates the Variables instance in use.abstract Actor
get(int index)
Returns the actor at the given position.abstract ActorHandlerInfo
getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.abstract int
indexOf(String actor)
Returns the index of the actor.protected void
initialize()
Initializes the members.boolean
isPaused()
Returns whether the object is currently paused.boolean
isSubFlowWrappedUp()
Checks whether the sub-flow has been wrapped up.Actor
lastActive()
Returns the last non-skipped actor.void
pauseExecution()
Pauses the execution.protected String
preExecute()
Pre-execute hook.protected void
reset()
Resets the actor.void
resumeExecution()
Resumes the execution.abstract String
set(int index, Actor actor)
Sets the actor at the given position.void
setParent(Actor value)
Sets the parent of this actor, e.g., the group it belongs to.String
setUp()
Initializes the sub-actors for flow execution.protected String
setUpSubActors()
Performs the setUp of the sub-actors.abstract int
size()
Returns the size of the group.void
stopExecution()
Stops the execution.protected void
updateParent()
Updates the parent of all actors in this group.void
wrapUp()
Finishes up the execution.void
wrapUpSubFlow()
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:
initialize
in classAbstractActor
-
reset
protected void reset()
Resets the actor.- Overrides:
reset
in classAbstractActor
-
setParent
public void setParent(Actor value)
Sets the parent of this actor, e.g., the group it belongs to.- Specified by:
setParent
in interfaceActor
- Overrides:
setParent
in classAbstractActor
- Parameters:
value
- the new parent
-
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
-
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:
getActorHandlerInfo
in interfaceActorHandler
- Returns:
- the info
-
size
public abstract int size()
Returns the size of the group.- Specified by:
size
in 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:
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
-
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:
get
in 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:
set
in 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:
indexOf
in 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:
canInspectOptions
in interfaceVariablesInspectionHandler
- Overrides:
canInspectOptions
in 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:
setUp
in interfaceActor
- Overrides:
setUp
in 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:
check
in interfaceActorHandler
- Returns:
- null
-
preExecute
protected String preExecute()
Pre-execute hook.
Attempts to setUp actor again, if it was wrapped up before.- Overrides:
preExecute
in 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:
flushExecution
in interfaceActorHandler
- Specified by:
flushExecution
in interfaceFlushable
-
wrapUp
public void wrapUp()
Finishes up the execution.- 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
-
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:
destroy
in interfaceActor
- Specified by:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classAbstractActor
- See Also:
AbstractOptionHandler.cleanUpOptions()
-
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
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecution
in interfaceActor
- Specified by:
stopExecution
in interfaceStoppable
- Overrides:
stopExecution
in classAbstractActor
-
flowPauseStateChanged
public void flowPauseStateChanged(FlowPauseStateEvent e)
Gets called when the pause state of the flow changes.
Default implementation does nothing.- Specified by:
flowPauseStateChanged
in interfaceFlowPauseStateListener
- Parameters:
e
- the event
-
wrapUpSubFlow
public void wrapUpSubFlow()
Wraps up the sub-actors, freeing up memory.- Specified by:
wrapUpSubFlow
in interfaceSubFlowWrapUp
-
isSubFlowWrappedUp
public boolean isSubFlowWrappedUp()
Checks whether the sub-flow has been wrapped up.- Specified by:
isSubFlowWrappedUp
in interfaceSubFlowWrapUp
- Returns:
- true if sub-flow was wrapped up
-
-