org.jbpm.graph.exe
Class ProcessInstance

java.lang.Object
  extended by org.jbpm.graph.exe.ProcessInstance
All Implemented Interfaces:
java.io.Serializable, Identifiable

public class ProcessInstance
extends java.lang.Object
implements Identifiable, java.io.Serializable

is one execution of a ProcessDefinition. To create a new process execution of a process definition, just use the ProcessInstance(ProcessDefinition).

See Also:
Serialized Form

Field Summary
protected  java.util.List cascadeProcessInstances
          not persisted
protected  java.util.Date end
           
protected  java.util.Map instances
           
protected  boolean isSuspended
           
protected  java.lang.String key
           
protected  ProcessDefinition processDefinition
           
protected  Token rootToken
           
protected  java.util.List runtimeActions
           
protected  java.util.Date start
           
protected  Token superProcessToken
           
protected  java.util.Map transientInstances
           
 
Constructor Summary
ProcessInstance()
           
ProcessInstance(ProcessDefinition processDefinition)
          creates a new process instance for the given process definition, puts the root-token (=main path of execution) in the start state and executes the initial node.
ProcessInstance(ProcessDefinition processDefinition, java.util.Map variables)
          creates a new process instance for the given process definition, puts the root-token (=main path of execution) in the start state and executes the initial node.
ProcessInstance(ProcessDefinition processDefinition, java.util.Map variables, java.lang.String key)
          creates a new process instance for the given process definition, puts the root-token (=main path of execution) in the start state and executes the initial node.
 
Method Summary
 void addInitialContextVariables(java.util.Map variables)
           
 void addInitialModuleDefinitions(ProcessDefinition processDefinition)
           
 ModuleInstance addInstance(ModuleInstance moduleInstance)
          adds the given optional moduleinstance (bidirectional).
 RuntimeAction addRuntimeAction(RuntimeAction runtimeAction)
          adds an action to be executed upon a process event in the future.
 void end()
          ends (=cancels) this process instance and all the tokens in it.
 boolean equals(java.lang.Object o)
           
 java.util.List findAllTokens()
          collects all instances for this process instance.
 Token findToken(java.lang.String tokenPath)
          looks up the token in the tree, specified by the slash-separated token path.
 void fireStartEvent(Node initialNode)
           
 ContextInstance getContextInstance()
          process instance extension for process variableInstances.
 java.util.Date getEnd()
           
 long getId()
           
 ModuleInstance getInstance(java.lang.Class clazz)
          looks up an optional module instance by its class.
 java.util.Map getInstances()
           
 java.lang.String getKey()
          a unique business key
 LoggingInstance getLoggingInstance()
          process instance extension for logging.
 ProcessDefinition getProcessDefinition()
           
 Token getRootToken()
           
 java.util.List getRuntimeActions()
          is the list of all runtime actions.
 java.util.Date getStart()
           
 Token getSuperProcessToken()
           
 TaskMgmtInstance getTaskMgmtInstance()
          process instance extension for managing the tasks and actors.
 int getVersion()
           
 boolean hasEnded()
          tells if this process instance is still active or not.
 int hashCode()
           
 boolean isSuspended()
           
 boolean isTerminatedImplicitly()
          calculates if this process instance has still options to continue.
 java.util.Collection removeCascadeProcessInstances()
           
 ModuleInstance removeInstance(ModuleInstance moduleInstance)
          removes the given optional moduleinstance (bidirectional).
 RuntimeAction removeRuntimeAction(RuntimeAction runtimeAction)
          removes a runtime action.
 void resume()
          resumes a suspended execution.
 void setEnd(java.util.Date end)
           
 void setKey(java.lang.String key)
          set the unique business key
 void setProcessDefinition(ProcessDefinition processDefinition)
           
 void setRootToken(Token rootToken)
           
 void setStart(java.util.Date start)
           
 void setSuperProcessToken(Token superProcessToken)
           
 void setVersion(int version)
           
 void signal()
          instructs the main path of execution to continue by taking the default transition on the current node.
 void signal(java.lang.String transitionName)
          instructs the main path of execution to continue by taking the specified transition on the current node.
 void signal(Transition transition)
          instructs the main path of execution to continue by taking the specified transition on the current node.
 void suspend()
          suspends this execution.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

key

protected java.lang.String key

start

protected java.util.Date start

end

protected java.util.Date end

processDefinition

protected ProcessDefinition processDefinition

rootToken

protected Token rootToken

superProcessToken

protected Token superProcessToken

isSuspended

protected boolean isSuspended

instances

protected java.util.Map instances

transientInstances

protected java.util.Map transientInstances

runtimeActions

protected java.util.List runtimeActions

cascadeProcessInstances

protected java.util.List cascadeProcessInstances
not persisted

Constructor Detail

ProcessInstance

public ProcessInstance()

ProcessInstance

public ProcessInstance(ProcessDefinition processDefinition)
creates a new process instance for the given process definition, puts the root-token (=main path of execution) in the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait state. For each of the optional module definitions contained in the ProcessDefinition, the corresponding module instance will be created.

Throws:
JbpmException - if processDefinition is null.

ProcessInstance

public ProcessInstance(ProcessDefinition processDefinition,
                       java.util.Map variables)
creates a new process instance for the given process definition, puts the root-token (=main path of execution) in the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait state. For each of the optional module definitions contained in the ProcessDefinition, the corresponding module instance will be created.

Parameters:
variables - will be inserted into the context variables after the context submodule has been created and before the process-start event is fired, which is also before the execution of the initial node.
Throws:
JbpmException - if processDefinition is null.

ProcessInstance

public ProcessInstance(ProcessDefinition processDefinition,
                       java.util.Map variables,
                       java.lang.String key)
creates a new process instance for the given process definition, puts the root-token (=main path of execution) in the start state and executes the initial node. In case the initial node is a start-state, it will behave as a wait state. For each of the optional module definitions contained in the ProcessDefinition, the corresponding module instance will be created.

Parameters:
variables - will be inserted into the context variables after the context submodule has been created and before the process-start event is fired, which is also before the execution of the initial node.
Throws:
JbpmException - if processDefinition is null.
Method Detail

addInitialContextVariables

public void addInitialContextVariables(java.util.Map variables)

addInitialModuleDefinitions

public void addInitialModuleDefinitions(ProcessDefinition processDefinition)

fireStartEvent

public void fireStartEvent(Node initialNode)

addInstance

public ModuleInstance addInstance(ModuleInstance moduleInstance)
adds the given optional moduleinstance (bidirectional).


removeInstance

public ModuleInstance removeInstance(ModuleInstance moduleInstance)
removes the given optional moduleinstance (bidirectional).


getInstance

public ModuleInstance getInstance(java.lang.Class clazz)
looks up an optional module instance by its class.


getContextInstance

public ContextInstance getContextInstance()
process instance extension for process variableInstances.


getTaskMgmtInstance

public TaskMgmtInstance getTaskMgmtInstance()
process instance extension for managing the tasks and actors.


getLoggingInstance

public LoggingInstance getLoggingInstance()
process instance extension for logging. Probably you don't need to access the logging instance directly. Mostly, Token.addLog(ProcessLog) is sufficient and more convenient.


signal

public void signal()
instructs the main path of execution to continue by taking the default transition on the current node.

Throws:
java.lang.IllegalStateException - if the token is not active.

signal

public void signal(java.lang.String transitionName)
instructs the main path of execution to continue by taking the specified transition on the current node.

Throws:
java.lang.IllegalStateException - if the token is not active.

signal

public void signal(Transition transition)
instructs the main path of execution to continue by taking the specified transition on the current node.

Throws:
java.lang.IllegalStateException - if the token is not active.

end

public void end()
ends (=cancels) this process instance and all the tokens in it.


suspend

public void suspend()
suspends this execution. This will make sure that tasks, timers and messages related to this process instance will not show up in database queries.

See Also:
resume()

resume

public void resume()
resumes a suspended execution. All timers that have been suspended might fire if the duedate has been passed. If an admin resumes a process instance, the option should be offered to update, remove and create the timers and messages related to this process instance.

See Also:
suspend()

addRuntimeAction

public RuntimeAction addRuntimeAction(RuntimeAction runtimeAction)
adds an action to be executed upon a process event in the future.


removeRuntimeAction

public RuntimeAction removeRuntimeAction(RuntimeAction runtimeAction)
removes a runtime action.


getRuntimeActions

public java.util.List getRuntimeActions()
is the list of all runtime actions.


hasEnded

public boolean hasEnded()
tells if this process instance is still active or not.


isTerminatedImplicitly

public boolean isTerminatedImplicitly()
calculates if this process instance has still options to continue.


findToken

public Token findToken(java.lang.String tokenPath)
looks up the token in the tree, specified by the slash-separated token path.

Parameters:
tokenPath - is a slash-separated name that specifies a token in the tree.
Returns:
the specified token or null if the token is not found.

findAllTokens

public java.util.List findAllTokens()
collects all instances for this process instance.


removeCascadeProcessInstances

public java.util.Collection removeCascadeProcessInstances()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getId

public long getId()
Specified by:
getId in interface Identifiable

getRootToken

public Token getRootToken()

getStart

public java.util.Date getStart()

getEnd

public java.util.Date getEnd()

getInstances

public java.util.Map getInstances()

getProcessDefinition

public ProcessDefinition getProcessDefinition()

getSuperProcessToken

public Token getSuperProcessToken()

setSuperProcessToken

public void setSuperProcessToken(Token superProcessToken)

isSuspended

public boolean isSuspended()

getVersion

public int getVersion()

setVersion

public void setVersion(int version)

setEnd

public void setEnd(java.util.Date end)

setProcessDefinition

public void setProcessDefinition(ProcessDefinition processDefinition)

setRootToken

public void setRootToken(Token rootToken)

setStart

public void setStart(java.util.Date start)

getKey

public java.lang.String getKey()
a unique business key


setKey

public void setKey(java.lang.String key)
set the unique business key



Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.