Class ProcessExecutor
- java.lang.Object
-
- jsl.modeling.elements.processview.description.ProcessExecutor
-
- Direct Known Subclasses:
SubProcessExecutor
public class ProcessExecutor extends java.lang.Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ProcessExecutor(ProcessDescription processDescription, Entity entity)
Creates a process executor given the supplied process description and entity
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAfterExecutionListener(ProcessExecutorListenerIfc listener)
Adds a listener to be called after the executionvoid
addBeforeExecutionListener(ProcessExecutorListenerIfc listener)
Adds a listener to be called prior to the executionProcessExecutor
createSubProcessExecutor(ProcessDescription processDescription)
Creates a sub-process executor on this executor that will execute the given process descriptionprotected void
execute()
The main method that executes commands within the ProcessExecutorprotected ProcessCommand
getCurrentCommand()
Gets the command associated with the current command index This method returns null if the index is not valid (out of range).int
getCurrentCommandIndex()
Returns an integer representing the location of the current command within process description, zero basedEntity
getCurrentEntity()
Gets the entity currently executingprotected int
getNextCommandIndex()
Used to get the command index that is next to be executedint
getNumberOfCommands()
Returns the total number of commands in the associated process descriptionvoid
initialize()
After being created the process executor must be intialized before being startedboolean
isCreated()
Checks if the process executor is in the created state.boolean
isExecuting()
Checks if the process executor is in the Executing state After the process executor has been resumed this method will return trueboolean
isInitialized()
Checks if the process executor is in the initialized state.boolean
isSuspended()
Checks if the process executor is in the suspended state After the process executor has been suspended this method will return trueboolean
isTerminated()
Checks if the process executor is in the terminated state After the process executor has been terminated this method will return truevoid
jumpTo(int commandIndex)
Cause the execution of the process executor to jump to the command indicated by the commandIndex.protected void
notifyAfterExecutionListeners()
Notifies the before execution listenersprotected void
notifyBeforeExecutionListeners()
Notifies the before execution listenersvoid
removeAfterExecutionListener(ProcessExecutorListenerIfc listener)
Removes the listener that is called after the executionvoid
removeBeforeExecutionListener(ProcessExecutorListenerIfc listener)
Removes the listener that is called prior to the executionvoid
resume()
Resumes the execution of the process executor at the next command after the previously executed commandvoid
resume(int commandIndex)
Resumes the execution of the process executor at the command indicated by the commandIndex.protected void
setCurrentCommandIndex(int index)
Sets the index to the current command.protected void
setState(jsl.modeling.elements.processview.description.ProcessExecutor.ProcessExecutorState state)
Used to set the state of the executorvoid
start()
Starts the process executor executing at the first command in the associated process descriptionvoid
start(int commandIndex)
Starts the process executor executing at the command indicated by the commandIndex.void
suspend()
Suspends the execution of the process executor at the current commandvoid
terminate()
Terminates the execution of the process executor
-
-
-
Constructor Detail
-
ProcessExecutor
protected ProcessExecutor(ProcessDescription processDescription, Entity entity)
Creates a process executor given the supplied process description and entity- Parameters:
processDescription
- the descriptionentity
- the entity
-
-
Method Detail
-
getNumberOfCommands
public final int getNumberOfCommands()
Returns the total number of commands in the associated process description- Returns:
- The number of commands in the associated process description
-
getCurrentCommandIndex
public final int getCurrentCommandIndex()
Returns an integer representing the location of the current command within process description, zero based- Returns:
- A integer representing the location of the command
-
getCurrentEntity
public final Entity getCurrentEntity()
Gets the entity currently executing- Returns:
- the entity
-
addBeforeExecutionListener
public final void addBeforeExecutionListener(ProcessExecutorListenerIfc listener)
Adds a listener to be called prior to the execution- Parameters:
listener
- the listener to add
-
removeBeforeExecutionListener
public final void removeBeforeExecutionListener(ProcessExecutorListenerIfc listener)
Removes the listener that is called prior to the execution- Parameters:
listener
- the listener to remove
-
addAfterExecutionListener
public final void addAfterExecutionListener(ProcessExecutorListenerIfc listener)
Adds a listener to be called after the execution- Parameters:
listener
- the listener to add
-
removeAfterExecutionListener
public final void removeAfterExecutionListener(ProcessExecutorListenerIfc listener)
Removes the listener that is called after the execution- Parameters:
listener
- the listener to remove
-
initialize
public final void initialize()
After being created the process executor must be intialized before being started
-
start
public final void start()
Starts the process executor executing at the first command in the associated process description
-
start
public void start(int commandIndex)
Starts the process executor executing at the command indicated by the commandIndex. Note: It is up to the user to ensure that the command is an appropriate location to start executing- Parameters:
commandIndex
- represents the index in the sequence of commands, index = 0, represents the first command- Throws:
java.lang.IndexOutOfBoundsException
- - if the index is out of range (index < 0 || index >= Number of commands).
-
resume
public final void resume()
Resumes the execution of the process executor at the next command after the previously executed command
-
resume
public void resume(int commandIndex)
Resumes the execution of the process executor at the command indicated by the commandIndex. Note: It is up to the user to ensure that the indicated command is an appropriate location to resume executing A command index out of range will cause the process executor to terminate- Parameters:
commandIndex
- the index to resume
-
jumpTo
public void jumpTo(int commandIndex)
Cause the execution of the process executor to jump to the command indicated by the commandIndex. Note: It is up to the user to ensure that the indicated command is an appropriate location to continue executing. This method is only valid in executing state. A command index out of range will cause the process executor to terminate- Parameters:
commandIndex
- the index to jump to
-
suspend
public void suspend()
Suspends the execution of the process executor at the current command
-
terminate
public void terminate()
Terminates the execution of the process executor
-
createSubProcessExecutor
public ProcessExecutor createSubProcessExecutor(ProcessDescription processDescription)
Creates a sub-process executor on this executor that will execute the given process description- Parameters:
processDescription
- the description- Returns:
- A process executor to execute the sub-process
-
isCreated
public final boolean isCreated()
Checks if the process executor is in the created state. After the process executor has been created this method will return true- Returns:
- true if created
-
isInitialized
public final boolean isInitialized()
Checks if the process executor is in the initialized state. After the process executor has been initialized this method will return true- Returns:
- true if initialized
-
isTerminated
public final boolean isTerminated()
Checks if the process executor is in the terminated state After the process executor has been terminated this method will return true- Returns:
- true if terminated
-
isSuspended
public final boolean isSuspended()
Checks if the process executor is in the suspended state After the process executor has been suspended this method will return true- Returns:
- true if suspended
-
isExecuting
public final boolean isExecuting()
Checks if the process executor is in the Executing state After the process executor has been resumed this method will return true- Returns:
- true if executing
-
getCurrentCommand
protected final ProcessCommand getCurrentCommand()
Gets the command associated with the current command index This method returns null if the index is not valid (out of range).- Returns:
- the command at the current command index
-
setCurrentCommandIndex
protected final void setCurrentCommandIndex(int index)
Sets the index to the current command. The indexing is zero based, i.e. 0=first command An index < 0 or > number of commands, implies no valid command, i.e. the current command will be null- Parameters:
index
- the index to set
-
execute
protected final void execute()
The main method that executes commands within the ProcessExecutor
-
getNextCommandIndex
protected final int getNextCommandIndex()
Used to get the command index that is next to be executed- Returns:
- the next index
-
setState
protected final void setState(jsl.modeling.elements.processview.description.ProcessExecutor.ProcessExecutorState state)
Used to set the state of the executor- Parameters:
state
- the state
-
notifyBeforeExecutionListeners
protected final void notifyBeforeExecutionListeners()
Notifies the before execution listeners
-
notifyAfterExecutionListeners
protected final void notifyAfterExecutionListeners()
Notifies the before execution listeners
-
-