org.ow2.bonita.pvm.internal.model
Class ExecutionImpl

java.lang.Object
  extended by org.ow2.bonita.pvm.internal.model.ExecutionImpl
All Implemented Interfaces:
java.io.Serializable, ActivityExecution, ClientExecution, ClientProcessInstance, Execution, EventListenerExecution, Discussable, OpenExecution

public class ExecutionImpl
extends java.lang.Object
implements ClientProcessInstance, ActivityExecution, EventListenerExecution, java.io.Serializable

Author:
Tom Baeyens
See Also:
Serialized Form

Nested Class Summary
static class ExecutionImpl.Propagation
           
 
Field Summary
protected  java.util.Queue<AtomicOperation> atomicOperations
          the queue of atomic operations to be performed for this execution.
protected  java.util.Set<CommentImpl> comments
          the free text comments users make on this execution
protected  long dbid
           
protected  int dbversion
           
protected  EventImpl event
           
protected  ObservableElementImpl eventSource
           
protected  java.lang.Exception exception
           
static AtomicOperation EXECUTE_NODE
           
protected  java.util.Collection<ExecutionImpl> executions
          are concurrent executions that related to this execution.
protected  java.util.Map<java.lang.String,OpenExecution> executionsMap
          caches the child executions by execution name.
protected  java.lang.String id
          a unique id for this execution.
protected  java.util.Set<JobImpl<?>> jobs
           
protected  java.lang.String key
          a key for this execution.
protected  java.lang.String name
          an optional name for this execution.
protected  int nextLogIndex
          maintains the index of the next log record.
protected  NodeImpl node
          current node
protected  ExecutionImpl parent
          the parent child relation of executions is convenient for some forms of concurrency.
protected  Node previousNode
           
protected  Transition previousTransition
           
protected  int priority
           
static AtomicOperation PROCEED_TO_DESTINATION
           
protected  PVMProcessDefinitionImpl processDefinition
           
protected  ExecutionImpl processInstance
           
protected  ProcessModificationsImpl processModifications
           
static AtomicOperation PROPAGATE_TO_PARENT
           
protected  ExecutionImpl.Propagation propagation
           
protected  java.lang.String state
           
protected  ExecutionImpl subProcessInstance
          the sub process link in case of sub process execution
protected  ExecutionImpl superProcessExecution
          the super process link in case this is a sub process execution
static AtomicOperation TAKE_TRANSITION
           
protected  TransitionImpl transition
          transition is not to be made persistable by default
protected  NodeImpl transitionOrigin
          the node from which the transition was taken.
protected  java.util.Map<java.lang.String,Variable> variables
           
 
Fields inherited from interface org.ow2.bonita.pvm.Execution
STATE_ACTIVE, STATE_ASYNC, STATE_CANCELLED, STATE_CREATED, STATE_ENDED, STATE_INACTIVE, STATE_SUSPENDED
 
Constructor Summary
ExecutionImpl()
           
 
Method Summary
 void addComment(CommentImpl comment)
           
 void addExecution(Execution execution)
           
 void addLog(ProcessLog processLog)
          adds a log to this execution.
 void begin()
          starts this process instance
 ExecutionImpl beginNode(NodeImpl node)
           
 ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition)
          creates and begins a sub process related to this path of execution.
 ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition, java.lang.String key)
          creates and begins a sub process related to this path of execution.
 void cancel()
          ends this execution and assigns the state Execution.STATE_CANCELLED.
protected  void checkLock()
           
 Comment createComment(java.lang.String message)
          create a comment
 ExecutionImpl createExecution()
          creates a child execution.
 Execution createExecution(Execution parent)
          creates a new child execution under the given parent.
 ExecutionImpl createExecution(java.lang.String name)
          creates a child execution with the given name.
 Execution createExecution(java.lang.String name, Execution parent)
          creates a new child execution under the given parent with the given name.
 ExecutionImpl createScope(CompositeElementImpl scope)
           
 ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition)
          creates a sub process related to this path of execution.
 ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition, java.lang.String key)
          creates a sub process related to this path of execution.
 void createTimer(java.lang.String eventName, java.lang.String signalName, java.lang.String dueDateDescription)
           
 void createTimer(java.lang.String eventName, java.lang.String signalName, java.lang.String dueDateDescription, java.util.Date dueDate, java.lang.String repeat, java.lang.Boolean isExclusive, java.lang.Integer retries)
           
 void createTimer(java.lang.String eventName, java.lang.String signalName, java.lang.String dueDateDescription, java.lang.String repeat)
           
 void createVariable(java.lang.String key, java.lang.Object value)
          create a new variable in this execution scope and determine the type automagically.
 void createVariable(java.lang.String key, java.lang.Object value, java.lang.String typeName)
          create a new variable in this execution scope with the given type name.
 void createVariable(java.lang.String key, java.lang.Object value, java.lang.String typeName, Type type)
           
 void createVariable(java.lang.String key, java.lang.Object value, Type type)
           
 ExecutionImpl destroyScope(CompositeElementImpl scope)
           
protected  void destroyTimers(CompositeElementImpl scope)
           
protected  void destroyVariables(CompositeElementImpl scope, ExecutionImpl outerExecution)
           
 void end()
          ends this execution and all of its child executions.
 void end(java.lang.String state)
          ends this execution and all it's child executions with a user defined status.
 ExecutionImpl endNode(NodeImpl node)
           
 boolean equals(java.lang.Object o)
           
 void execute(Node node)
          executes the given node.
 void execute(java.lang.String nodeName)
          executes the given nested node.
protected  TransitionImpl findDefaultTransition()
           
protected  TransitionImpl findTransition(java.lang.String transitionName)
          by default this will use NodeImpl.findOutgoingTransition(String) to search for the outgoing transition, which includes a search over the parent chain of the current node.
 void fire(java.lang.String eventName, ObservableElement eventSource)
          fires the event on the given eventSource and then propagates the event up to the eventSource's parent chain.
 java.util.List<Comment> getComments()
          all comments.
 long getDbid()
           
 Event getEvent()
          the event that is being fired, part of the current position in the process graph.
 ObservableElement getEventSource()
          the original object that fired the event, part of the current position in the process graph.
 java.lang.Exception getException()
          the exception in case an exception handler is handling an exception.
 ExecutionImpl getExecution(java.lang.String name)
          the child execution for the given name or null in case such execution doesn't exist.
 java.util.Collection<OpenExecution> getExecutions()
          the child executions in the execution structure.
 java.util.Map<java.lang.String,OpenExecution> getExecutionsMap()
          maps child execution names to execution objects.
<T> T
getExtension(java.lang.Class<T> extensionClass)
          way to access process language extensions in the execution without having to cast.
 java.lang.String getId()
          a globally unique identifier for this execution.
 java.util.Set<Job> getJobs()
          timers for this execution scope
 java.lang.String getKey()
          the optional user provided business key that is unique within one process definition.
 java.lang.String getName()
          the externally given name or id of this execution.
 NodeImpl getNode()
          the current node
 java.lang.String getNodeName()
          represents the current position in the process by indicating the name of the current node.
 ExecutionImpl getParent()
          the parent execution in the execution structure.
 Node getPreviousNode()
          returns the previously executed node only if Node.isPreviousNeeded() is set to true.
 Transition getPreviousTransition()
          returns the previously taken transition only if Node.isPreviousNeeded() is set to true.
 int getPriority()
          indicates low priorities with negative values and high priorities with positive values.
 PVMProcessDefinitionImpl getProcessDefinition()
          the process definition for this execution.
 ExecutionImpl getProcessInstance()
          the main path of execution in the execution structure.
 ProcessModificationsImpl getProcessModifications()
           
 ExecutionImpl.Propagation getPropagation()
           
 java.lang.String getState()
          the state of this execution.
 ExecutionImpl getSubProcessInstance()
          the related sub process execution.
 ExecutionImpl getSuperProcessExecution()
           
 TransitionImpl getTransition()
          the current transition indicating the position in the process definition graph.
 NodeImpl getTransitionOrigin()
           
 java.lang.Object getVariable(java.lang.String key)
          retrieve the value for the given key.
 java.util.Set<java.lang.String> getVariableKeys()
          a non-null set that contains all the keys present in this scope.
 Variable getVariableObject(java.lang.String key)
           
 java.util.Map<java.lang.String,java.lang.Object> getVariables()
          a non-null map containing all the key-value pairs in this scope.
 void handleException(ObservableElementImpl observableElement, EventImpl event, EventListenerReference eventListenerReference, java.lang.Exception exception, java.lang.String rethrowMessage)
           
 boolean hasExecution(java.lang.String name)
          indicates if this execution has a child execution with the given executionName
 boolean hasVariable(java.lang.String key)
          indicates presenve of the given key.
 boolean hasVariables()
          indicates if there are keys in this scope.
 void initializeProcessInstance(PVMProcessDefinitionImpl processDefinition, java.lang.String key)
           
protected  ExecutionImpl initializeScopes()
           
protected  void initializeTimers(CompositeElementImpl scope)
           
protected  void initializeVariables(CompositeElementImpl scope, ExecutionImpl outerExecution)
           
protected  TimerImpl instantiateTimer()
           
 boolean isActive()
          is this execution active ? This is the inverse of Execution.isLocked().
 boolean isEnded()
          is this execution ended normally ?
 boolean isFinished()
          is this execution ended or cancelled ?
 boolean isLocked()
          is this execution locked ? This is the inverse of Execution.isActive().
 boolean isSuspended()
          is this execution suspended ?
 void lock(java.lang.String state)
           
 void move(Node destination)
          position this execution in the destination node.
 void move(Node destination, Execution execution)
          position the given execution in the destination node
 void moveTo(NodeImpl destination)
           
protected  ExecutionImpl newChildExecution()
           
 int nextLogIndex()
           
 void performAtomicOperation(AtomicOperation operation)
           
 void performAtomicOperationSync(AtomicOperation operation)
           
 void proceed()
           
protected  void propagateEvent(java.lang.String eventName, ObservableElement eventSource, ObservableElementImpl observableElement)
          this method enables specific process languages to overwrite the event propagation behaviour
 void removeComment(Comment comment)
          remove a comment
 void removeExecution(Execution child)
          removes the child execution from this execution.
 void removeExecution(Execution child, Execution parent)
          removes the child execution from the given parent.
 boolean removeVariable(java.lang.String key)
          remove the key-value pair for the given key from this scope.
 void removeVariables()
          removes all variables in this scope
 void resume()
          resumes an execution.
 void sendContinuationMessage(AtomicOperation operation)
           
 void setComments(java.util.Set<CommentImpl> comments)
           
 void setEvent(EventImpl event)
           
 void setEventSource(ObservableElementImpl eventSource)
           
 void setException(java.lang.Exception exception)
           
 void setExecutions(java.util.Collection<ExecutionImpl> executions)
           
 void setId(java.lang.String id)
           
 void setKey(java.lang.String key)
           
 void setName(java.lang.String name)
           
 void setNode(NodeImpl node)
           
 void setParent(ExecutionImpl parent)
           
 void setPreviousNode(Node previousNode)
           
 void setPreviousTransition(Transition previousTransition)
           
 void setPriority(int priority)
          setter for the priority.
 void setProcessDefinition(PVMProcessDefinitionImpl processDefinition)
           
 void setProcessInstance(ExecutionImpl processInstance)
           
 void setProcessModifications(ProcessModificationsImpl processModifications)
           
 void setPropagation(ExecutionImpl.Propagation propagation)
           
 void setState(java.lang.String state)
           
 void setSubProcessInstance(ExecutionImpl subProcessExecution)
           
 void setSuperProcessExecution(ExecutionImpl superProcessExecution)
           
 void setTransition(TransitionImpl transition)
           
 void setTransitionOrigin(NodeImpl transitionOrigin)
           
 void setVariable(java.lang.String key, java.lang.Object value)
          updates or creates a variable for the given value.
 void setVariables(java.util.Map<java.lang.String,java.lang.Object> variables)
          sets all given variables.
 void signal()
          feeds a external trigger into this execution.
 void signal(Execution execution)
          feeds a external trigger into the given execution.
 void signal(java.util.Map<java.lang.String,java.lang.Object> parameters)
          feeds an external trigger into the execution with parameters.
 void signal(java.util.Map<java.lang.String,java.lang.Object> parameters, Execution execution)
          feeds an external trigger into a given execution with parameters.
 void signal(java.lang.String signal)
          feeds a named external trigger into the execution.
 void signal(java.lang.String signalName, Execution execution)
          feeds a named external trigger into a given execution.
 void signal(java.lang.String signal, java.util.Map<java.lang.String,java.lang.Object> parameters)
          feeds a named external trigger into the execution with parameters.
 void signal(java.lang.String signalName, java.util.Map<java.lang.String,java.lang.Object> parameters, Execution execution)
          feeds a named external trigger into a given execution with parameters.
 void suspend()
          suspends this execution and all it's child executions.
 void take(java.lang.String transitionName)
          takes the outgoing transition with the given name.
 void take(Transition transition)
          takes the given outgoing transition.
 void take(Transition transition, Execution execution)
          let's the given execution take the transition.
 void takeDefaultTransition()
          takes the default transition.
 java.lang.String toString()
           
 void unlock()
           
 void waitForSignal()
          makes this execution wait in the current node until an external trigger is given with one of the #signal() methods.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXECUTE_NODE

public static final AtomicOperation EXECUTE_NODE

PROCEED_TO_DESTINATION

public static final AtomicOperation PROCEED_TO_DESTINATION

TAKE_TRANSITION

public static final AtomicOperation TAKE_TRANSITION

PROPAGATE_TO_PARENT

public static final AtomicOperation PROPAGATE_TO_PARENT

dbid

protected long dbid

dbversion

protected int dbversion

name

protected java.lang.String name
an optional name for this execution. can be used to differentiate concurrent paths of execution like e.g. the 'shipping' and 'billing' paths.


key

protected java.lang.String key
a key for this execution. typically this is an externally provided reference that is unique within the scope of the process definition.


id

protected java.lang.String id
a unique id for this execution.


state

protected java.lang.String state
See Also:
Execution

processDefinition

protected PVMProcessDefinitionImpl processDefinition

node

protected NodeImpl node
current node


transition

protected TransitionImpl transition
transition is not to be made persistable by default


transitionOrigin

protected NodeImpl transitionOrigin
the node from which the transition was taken. This can be different from the transition source in case a transition of an eclosing node was taken. transitionOrigin is not to be made persistable by default


event

protected EventImpl event

eventSource

protected ObservableElementImpl eventSource

executions

protected java.util.Collection<ExecutionImpl> executions
are concurrent executions that related to this execution.


parent

protected ExecutionImpl parent
the parent child relation of executions is convenient for some forms of concurrency.


processInstance

protected ExecutionImpl processInstance

variables

protected java.util.Map<java.lang.String,Variable> variables

jobs

protected java.util.Set<JobImpl<?>> jobs

superProcessExecution

protected ExecutionImpl superProcessExecution
the super process link in case this is a sub process execution


subProcessInstance

protected ExecutionImpl subProcessInstance
the sub process link in case of sub process execution


comments

protected java.util.Set<CommentImpl> comments
the free text comments users make on this execution


priority

protected int priority

nextLogIndex

protected int nextLogIndex
maintains the index of the next log record. That way, the logs don't have to be loaded to add one. Instead, for each log that is added to this execution, the nextLogIndex is used and incremented.


executionsMap

protected transient java.util.Map<java.lang.String,OpenExecution> executionsMap
caches the child executions by execution name. This member might be null and is only created from the executions in case its needed. Note that not all executions are forced to have a name and duplicates are allowed. In case the executions change, the executionsMap can be nulled or also updated (but a check needs to be added whether it exists).


atomicOperations

protected java.util.Queue<AtomicOperation> atomicOperations
the queue of atomic operations to be performed for this execution.


propagation

protected ExecutionImpl.Propagation propagation

previousNode

protected Node previousNode

previousTransition

protected Transition previousTransition

exception

protected java.lang.Exception exception

processModifications

protected ProcessModificationsImpl processModifications
Constructor Detail

ExecutionImpl

public ExecutionImpl()
Method Detail

initializeProcessInstance

public void initializeProcessInstance(PVMProcessDefinitionImpl processDefinition,
                                      java.lang.String key)

begin

public void begin()
Description copied from interface: ClientProcessInstance
starts this process instance

Specified by:
begin in interface ClientProcessInstance

initializeScopes

protected ExecutionImpl initializeScopes()

createScope

public ExecutionImpl createScope(CompositeElementImpl scope)

destroyScope

public ExecutionImpl destroyScope(CompositeElementImpl scope)

toString

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

end

public void end()
Description copied from interface: ActivityExecution
ends this execution and all of its child executions.

The execution will be removed from it's parent. Potentially this can cause a parent execution to start executing in case this is the last concurrent execution for which the parent is waiting.

This method should not be called in Activitys. It can be called from outside the process execution and in ExternalActivitys.

Specified by:
end in interface ActivityExecution
Specified by:
end in interface ClientExecution

end

public void end(java.lang.String state)
Description copied from interface: ActivityExecution
ends this execution and all it's child executions with a user defined status.

It is not recommended to use any of the defined statuses as that may case unpredictable side effects.

The execution will be removed from it's parent.

Specified by:
end in interface ActivityExecution
Specified by:
end in interface ClientExecution

cancel

public void cancel()
Description copied from interface: ActivityExecution
ends this execution and assigns the state Execution.STATE_CANCELLED.

Specified by:
cancel in interface ActivityExecution
Specified by:
cancel in interface ClientExecution
See Also:
ActivityExecution.end(String)

suspend

public void suspend()
Description copied from interface: ClientExecution
suspends this execution and all it's child executions. Human tasks of a suspended execution shouldn't show up in people's task list and timers of suspended executions shouldn't fire.

Specified by:
suspend in interface ClientExecution
See Also:
Execution#suspend()

resume

public void resume()
Description copied from interface: ClientExecution
resumes an execution. Inverse of ClientExecution.suspend().

Specified by:
resume in interface ClientExecution
See Also:
Execution#resume()

signal

public void signal()
Description copied from interface: ClientExecution
feeds a external trigger into this execution.

Typically a signal causes the execution to proceed, but that doesn't necessarily has to be the case . The ExternalActivity is responsible for interpreting the signal and acting upon it.

A signal can optionally be given a signal name, a map of parameters or both.

Since it's an external trigger, this method requires that this execution is waiting for an external trigger. So this method must be called as an external client and can not be called while this execution is executing. In an Activity for example you're not allowed to call the signal on the execution cause it is executing. But you are allowed to invoke this method on any other execution (at least, if that one is waiting for an external trigger).

Typically a signal will cause the execution to start executing, but that is not a must. What happens with this signal is defined in the ExternalActivity#signal(Execution, String, Map) of the current node.

Specified by:
signal in interface ClientExecution
See Also:
ClientExecution.signal(String)

signal

public void signal(java.lang.String signal)
Description copied from interface: ClientExecution
feeds a named external trigger into the execution.

In each state, a number of things can happen. The signal parameter specifies which of these things is happening. It's somewhat similar to a method name in the invocation of an object.

Specified by:
signal in interface ClientExecution
See Also:
See the unnamed signal for more information

signal

public void signal(java.util.Map<java.lang.String,java.lang.Object> parameters)
Description copied from interface: ClientExecution
feeds an external trigger into the execution with parameters.

Specified by:
signal in interface ClientExecution
See Also:
See the unnamed signal for more information

signal

public void signal(java.lang.String signal,
                   java.util.Map<java.lang.String,java.lang.Object> parameters)
Description copied from interface: ClientExecution
feeds a named external trigger into the execution with parameters.

In each state, a number of things can happen. The signal parameter specifies which of these things is happening. It's somewhat similar to a method name in the invocation of an object.

The parameters parameter provide extra information to the signal. Typically, the parameters are set as variables but the process language can overwrite that behaviour in the current node. See ExternalActivity#signal(Execution, String, Map) for more information.

Specified by:
signal in interface ClientExecution
See Also:
See the unnamed signal for more information

signal

public void signal(Execution execution)
Description copied from interface: ClientExecution
feeds a external trigger into the given execution.

Typically a signal causes the execution to proceed, but that doesn't necessarily has to be the case . The ExternalActivity is responsible for interpreting the signal and acting upon it.

A signal can optionally be given a signal name, a map of parameters or both.

Since it's an external trigger, this method requires that this execution is waiting for an external trigger. So this method must be called as an external client and can not be called while this execution is executing. In an Activity for example you're not allowed to call the signal on the execution cause it is executing. But you are allowed to invoke this method on any other execution (at least, if that one is waiting for an external trigger).

Typically a signal will cause the execution to start executing, but that is not a must. What happens with this signal is defined in the ExternalActivity#signal(Execution, String, Map) of the current node.

Specified by:
signal in interface ClientExecution
See Also:
ClientExecution.signal(String)

signal

public void signal(java.lang.String signalName,
                   Execution execution)
Description copied from interface: ClientExecution
feeds a named external trigger into a given execution.

In each state, a number of things can happen. The signal parameter specifies which of these things is happening. It's somewhat similar to a method name in the invocation of an object.

Specified by:
signal in interface ClientExecution
See Also:
See the unnamed signal for more information

signal

public void signal(java.util.Map<java.lang.String,java.lang.Object> parameters,
                   Execution execution)
Description copied from interface: ClientExecution
feeds an external trigger into a given execution with parameters.

Specified by:
signal in interface ClientExecution
See Also:
See the unnamed signal for more information

signal

public void signal(java.lang.String signalName,
                   java.util.Map<java.lang.String,java.lang.Object> parameters,
                   Execution execution)
Description copied from interface: ClientExecution
feeds a named external trigger into a given execution with parameters.

In each state, a number of things can happen. The signal parameter specifies which of these things is happening. It's somewhat similar to a method name in the invocation of an object.

The parameters parameter provide extra information to the signal. Typically, the parameters are set as variables but the process language can overwrite that behaviour in the current node. See ExternalActivity#signal(Execution, String, Map) for more information.

Specified by:
signal in interface ClientExecution
See Also:
See the unnamed signal for more information

takeDefaultTransition

public void takeDefaultTransition()
Description copied from interface: ActivityExecution
takes the default transition.

This method can only be called from inside ExternalActivity implementations and in rare occasions also from outside of the execution (from an external client while the process is in a wait state). For external clients, it is more normal to use the #signal() method as in that case, it's the current node (hence the process language)that will decide how to interpret the signal.

Specified by:
takeDefaultTransition in interface ActivityExecution
See Also:
Execution#takeDefaultTransition()

take

public void take(java.lang.String transitionName)
Description copied from interface: ActivityExecution
takes the outgoing transition with the given name.

This method can only be called from inside ExternalActivity implementations and in rare occasions also from outside of the execution (from an external client while the process is in a wait state). For external clients, it is more normal to use the #signal(String) method as in that case, it's the current node (hence the process language)that will decide how to interpret the signal.

Transitions will be looked up recursively starting from the current node and then up the node-parent-hierarchy

Specified by:
take in interface ActivityExecution
Parameters:
transitionName - is the name of the transition to take. A null value will match the first unnamed transition.
See Also:
Execution#take(String)

take

public void take(Transition transition)
Description copied from interface: ActivityExecution
takes the given outgoing transition.

This method can only be called from inside ExternalActivity implementations and in rare occasions also from outside of the execution (from an external client while the process is in a wait state). For external clients, it is more normal to use the #signal(String) method as in that case, it's the current node (hence the process language)that will decide how to interpret the signal.

CAUTION: It's up to the client to make sure that this transition makes sense as there is no check whether the given transition is an outgoing transition of the current node. The motivation for that is that in case of superstates, that check can become too 'expensive'.

Specified by:
take in interface ActivityExecution
See Also:
Execution#takeDefaultTransition()

take

public void take(Transition transition,
                 Execution execution)
Description copied from interface: ActivityExecution
let's the given execution take the transition.

Specified by:
take in interface ActivityExecution

execute

public void execute(java.lang.String nodeName)
Description copied from interface: ActivityExecution
executes the given nested node.

The nodeName is looked up in the current node's nested nodes.

This method can only be called from inside ExternalActivity implementations and in rare occasions also from outside of the execution (from an external client while the process is in a wait state). For external clients, it is more normal to use the #signal(String) method as in that case, it's the current node (hence the process language)that will decide how to interpret the signal.

Specified by:
execute in interface ActivityExecution
See Also:
Execution#execute(String)

execute

public void execute(Node node)
Description copied from interface: ActivityExecution
executes the given node.

This method can only be called from inside ExternalActivity implementations and in rare occasions also from outside of the execution (from an external client while the process is in a wait state). For external clients, it is more normal to use the #signal(String) method as in that case, it's the current node (hence the process language)that will decide how to interpret the signal.

Specified by:
execute in interface ActivityExecution
See Also:
Execution#execute(Node)

waitForSignal

public void waitForSignal()
Description copied from interface: ActivityExecution
makes this execution wait in the current node until an external trigger is given with one of the #signal() methods.

Specified by:
waitForSignal in interface ActivityExecution

proceed

public void proceed()

move

public void move(Node destination,
                 Execution execution)
Description copied from interface: ActivityExecution
position the given execution in the destination node

Specified by:
move in interface ActivityExecution

move

public void move(Node destination)
Description copied from interface: ActivityExecution
position this execution in the destination node.

Specified by:
move in interface ActivityExecution

moveTo

public void moveTo(NodeImpl destination)

beginNode

public ExecutionImpl beginNode(NodeImpl node)

endNode

public ExecutionImpl endNode(NodeImpl node)

performAtomicOperation

public void performAtomicOperation(AtomicOperation operation)

initializeVariables

protected void initializeVariables(CompositeElementImpl scope,
                                   ExecutionImpl outerExecution)

destroyVariables

protected void destroyVariables(CompositeElementImpl scope,
                                ExecutionImpl outerExecution)

createVariable

public void createVariable(java.lang.String key,
                           java.lang.Object value)
Description copied from interface: OpenExecution
create a new variable in this execution scope and determine the type automagically.

Specified by:
createVariable in interface OpenExecution

createVariable

public void createVariable(java.lang.String key,
                           java.lang.Object value,
                           java.lang.String typeName)
Description copied from interface: OpenExecution
create a new variable in this execution scope with the given type name.

Specified by:
createVariable in interface OpenExecution

createVariable

public void createVariable(java.lang.String key,
                           java.lang.Object value,
                           Type type)

createVariable

public void createVariable(java.lang.String key,
                           java.lang.Object value,
                           java.lang.String typeName,
                           Type type)

setVariable

public void setVariable(java.lang.String key,
                        java.lang.Object value)
Description copied from interface: OpenExecution
updates or creates a variable for the given value. Values are allowed to be null.

Specified by:
setVariable in interface OpenExecution

setVariables

public void setVariables(java.util.Map<java.lang.String,java.lang.Object> variables)
Description copied from interface: OpenExecution
sets all given variables. Existing key-value pairs for which there is no key in the provided variables will not be removed.

Specified by:
setVariables in interface OpenExecution

getVariable

public java.lang.Object getVariable(java.lang.String key)
Description copied from interface: OpenExecution
retrieve the value for the given key. The value can be null. If there is no value for the given key, the returned value will also be null. The value for key null will always be null as null keys are not allowed.

Specified by:
getVariable in interface OpenExecution

getVariableObject

public Variable getVariableObject(java.lang.String key)

hasVariable

public boolean hasVariable(java.lang.String key)
Description copied from interface: OpenExecution
indicates presenve of the given key. No exception will be thrown if key is null.

Specified by:
hasVariable in interface OpenExecution
Returns:
true if the key is present and false if the key doesn't exist or if key is null.

getVariableKeys

public java.util.Set<java.lang.String> getVariableKeys()
Description copied from interface: OpenExecution
a non-null set that contains all the keys present in this scope. Even if there are no variable keys, an empty, non-null set will be returned.

Specified by:
getVariableKeys in interface OpenExecution

getVariables

public java.util.Map<java.lang.String,java.lang.Object> getVariables()
Description copied from interface: OpenExecution
a non-null map containing all the key-value pairs in this scope. Even if there are no variable keys, an empty, non-null map will be returned.

Specified by:
getVariables in interface OpenExecution

hasVariables

public boolean hasVariables()
Description copied from interface: OpenExecution
indicates if there are keys in this scope.

Specified by:
hasVariables in interface OpenExecution

removeVariable

public boolean removeVariable(java.lang.String key)
Description copied from interface: OpenExecution
remove the key-value pair for the given key from this scope. No exception will be thrown when the variable is not present.

Specified by:
removeVariable in interface OpenExecution

removeVariables

public void removeVariables()
Description copied from interface: OpenExecution
removes all variables in this scope

Specified by:
removeVariables in interface OpenExecution

initializeTimers

protected void initializeTimers(CompositeElementImpl scope)

destroyTimers

protected void destroyTimers(CompositeElementImpl scope)

createTimer

public void createTimer(java.lang.String eventName,
                        java.lang.String signalName,
                        java.lang.String dueDateDescription)

createTimer

public void createTimer(java.lang.String eventName,
                        java.lang.String signalName,
                        java.lang.String dueDateDescription,
                        java.lang.String repeat)

createTimer

public void createTimer(java.lang.String eventName,
                        java.lang.String signalName,
                        java.lang.String dueDateDescription,
                        java.util.Date dueDate,
                        java.lang.String repeat,
                        java.lang.Boolean isExclusive,
                        java.lang.Integer retries)

getJobs

public java.util.Set<Job> getJobs()
Description copied from interface: OpenExecution
timers for this execution scope

Specified by:
getJobs in interface OpenExecution

instantiateTimer

protected TimerImpl instantiateTimer()

getState

public java.lang.String getState()
Description copied from interface: Execution
the state of this execution.

Specified by:
getState in interface Execution
See Also:
Execution.getState()

lock

public void lock(java.lang.String state)
See Also:
Execution#lock(String)

unlock

public void unlock()
See Also:
Execution#unlock()

isActive

public boolean isActive()
Description copied from interface: Execution
is this execution active ? This is the inverse of Execution.isLocked().

Specified by:
isActive in interface Execution
See Also:
Execution.isActive()

isLocked

public boolean isLocked()
Description copied from interface: Execution
is this execution locked ? This is the inverse of Execution.isActive().

Specified by:
isLocked in interface Execution
See Also:
Execution.isLocked()

isSuspended

public boolean isSuspended()
Description copied from interface: Execution
is this execution suspended ?

Specified by:
isSuspended in interface Execution
See Also:
Execution.isSuspended()

isEnded

public boolean isEnded()
Description copied from interface: Execution
is this execution ended normally ?

Specified by:
isEnded in interface Execution
See Also:
Execution.isEnded()

isFinished

public boolean isFinished()
Description copied from interface: Execution
is this execution ended or cancelled ?

Specified by:
isFinished in interface Execution
See Also:
Execution.isFinished()

checkLock

protected void checkLock()

sendContinuationMessage

public void sendContinuationMessage(AtomicOperation operation)

performAtomicOperationSync

public void performAtomicOperationSync(AtomicOperation operation)

fire

public void fire(java.lang.String eventName,
                 ObservableElement eventSource)
Description copied from interface: ActivityExecution
fires the event on the given eventSource and then propagates the event up to the eventSource's parent chain. All the actions will see the given eventSource in #getEventSource(), event if the events are registered to parent's of the given eventSource.

Specified by:
fire in interface ActivityExecution
Specified by:
fire in interface EventListenerExecution
See Also:
Execution#fire(String, ObservableElement)

propagateEvent

protected void propagateEvent(java.lang.String eventName,
                              ObservableElement eventSource,
                              ObservableElementImpl observableElement)
this method enables specific process languages to overwrite the event propagation behaviour


handleException

public void handleException(ObservableElementImpl observableElement,
                            EventImpl event,
                            EventListenerReference eventListenerReference,
                            java.lang.Exception exception,
                            java.lang.String rethrowMessage)

createComment

public Comment createComment(java.lang.String message)
Description copied from interface: Discussable
create a comment

Specified by:
createComment in interface Discussable

removeComment

public void removeComment(Comment comment)
Description copied from interface: Discussable
remove a comment

Specified by:
removeComment in interface Discussable

addComment

public void addComment(CommentImpl comment)

createExecution

public ExecutionImpl createExecution()
Description copied from interface: ActivityExecution
creates a child execution. See #createExecution(Execution, String) for more information.

Specified by:
createExecution in interface ActivityExecution
See Also:
Execution#createProcessInstance()

createExecution

public Execution createExecution(Execution parent)
Description copied from interface: ActivityExecution
creates a new child execution under the given parent. See #createExecution(Execution, String) for more information.

Specified by:
createExecution in interface ActivityExecution

createExecution

public Execution createExecution(java.lang.String name,
                                 Execution parent)
Description copied from interface: ActivityExecution
creates a new child execution under the given parent with the given name. Only leaf executions can be active. So creating the first child execution will inactivate the parent execution automatically.

Specified by:
createExecution in interface ActivityExecution

createExecution

public ExecutionImpl createExecution(java.lang.String name)
Description copied from interface: ActivityExecution
creates a child execution with the given name. See #createExecution(Execution, String) for more information.

Specified by:
createExecution in interface ActivityExecution
See Also:
Execution#createProcessInstance(String)

newChildExecution

protected ExecutionImpl newChildExecution()

addExecution

public void addExecution(Execution execution)

getExecution

public ExecutionImpl getExecution(java.lang.String name)
Description copied from interface: OpenExecution
the child execution for the given name or null in case such execution doesn't exist.

Specified by:
getExecution in interface OpenExecution
See Also:
Execution#getExecution(String)

removeExecution

public void removeExecution(Execution child)
Description copied from interface: ActivityExecution
removes the child execution from this execution. Removing the last child execution of a parent will cause the parent's state to become active.

Specified by:
removeExecution in interface ActivityExecution

removeExecution

public void removeExecution(Execution child,
                            Execution parent)
Description copied from interface: ActivityExecution
removes the child execution from the given parent. Removing the last child execution of a parent will cause the parent's state to become active.

Specified by:
removeExecution in interface ActivityExecution

getExecutionsMap

public java.util.Map<java.lang.String,OpenExecution> getExecutionsMap()
Description copied from interface: OpenExecution
maps child execution names to execution objects. In case multiple executions have the same name, the first one is taken. Can be null or can be an empty map. The first execution without a name is also included with null as the key.

Specified by:
getExecutionsMap in interface OpenExecution

hasExecution

public boolean hasExecution(java.lang.String name)
Description copied from interface: OpenExecution
indicates if this execution has a child execution with the given executionName

Specified by:
hasExecution in interface OpenExecution

createSubProcessInstance

public ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition)
Description copied from interface: ActivityExecution
creates a sub process related to this path of execution. ProcessDefinitions can be obtained from the PvmDbSession in the Environment.

Specified by:
createSubProcessInstance in interface ActivityExecution

createSubProcessInstance

public ClientProcessInstance createSubProcessInstance(ClientProcessDefinition processDefinition,
                                                      java.lang.String key)
Description copied from interface: ActivityExecution
creates a sub process related to this path of execution. ProcessDefinitions can be obtained from the PvmDbSession in the Environment.

Specified by:
createSubProcessInstance in interface ActivityExecution

beginSubProcessInstance

public ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition)
Description copied from interface: ActivityExecution
creates and begins a sub process related to this path of execution. ProcessDefinitions can be obtained from the PvmDbSession in the Environment.

Specified by:
beginSubProcessInstance in interface ActivityExecution

beginSubProcessInstance

public ClientProcessInstance beginSubProcessInstance(ClientProcessDefinition processDefinition,
                                                     java.lang.String key)
Description copied from interface: ActivityExecution
creates and begins a sub process related to this path of execution. ProcessDefinitions can be obtained from the PvmDbSession in the Environment.

Specified by:
beginSubProcessInstance in interface ActivityExecution

getNodeName

public java.lang.String getNodeName()
Description copied from interface: Execution
represents the current position in the process by indicating the name of the current node.

Specified by:
getNodeName in interface Execution

addLog

public void addLog(ProcessLog processLog)
Description copied from interface: ActivityExecution
adds a log to this execution.

Specified by:
addLog in interface ActivityExecution
Specified by:
addLog in interface EventListenerExecution

nextLogIndex

public int nextLogIndex()

findTransition

protected TransitionImpl findTransition(java.lang.String transitionName)
by default this will use NodeImpl.findOutgoingTransition(String) to search for the outgoing transition, which includes a search over the parent chain of the current node. This method allows process languages to overwrite this default implementation of the transition lookup by transitionName.


findDefaultTransition

protected TransitionImpl findDefaultTransition()

getExtension

public <T> T getExtension(java.lang.Class<T> extensionClass)
Description copied from interface: ActivityExecution
way to access process language extensions in the execution without having to cast. Casting can be problematic for persistence.

Specified by:
getExtension in interface ActivityExecution
Specified by:
getExtension in interface EventListenerExecution

equals

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

getComments

public java.util.List<Comment> getComments()
Description copied from interface: Discussable
all comments.

Specified by:
getComments in interface Discussable

getEvent

public Event getEvent()
Description copied from interface: EventListenerExecution
the event that is being fired, part of the current position in the process graph. Can be null in case no event is being fired.

Specified by:
getEvent in interface EventListenerExecution

getEventSource

public ObservableElement getEventSource()
Description copied from interface: EventListenerExecution
the original object that fired the event, part of the current position in the process graph. Can be null in case no event is being fired. This is mostly the object that is listened to with an Activity, but the eventSource can also be a child of the object to which is listened in case of event propagation.

Specified by:
getEventSource in interface EventListenerExecution

getExecutions

public java.util.Collection<OpenExecution> getExecutions()
Description copied from interface: OpenExecution
the child executions in the execution structure. Can be null and can be an empty collection.

Specified by:
getExecutions in interface OpenExecution

getName

public java.lang.String getName()
Description copied from interface: Execution
the externally given name or id of this execution. The id of a main path of execution is null. Can be used to differentiate concurrent paths of execution e.g. the shipping and billing paths.

Specified by:
getName in interface Execution

getParent

public ExecutionImpl getParent()
Description copied from interface: OpenExecution
the parent execution in the execution structure. Null will be returned in case this execution itself is the main execution path.

Specified by:
getParent in interface OpenExecution

getPriority

public int getPriority()
Description copied from interface: Execution
indicates low priorities with negative values and high priorities with positive values. The default priority is 0, which means NORMAL. Other recognized named priorities are HIGHEST (2), HIGH (1), LOW (-1) and LOWEST (-2). For the rest, the user can set any other priority integer value, but then, the UI will have to display it as an integer and not the named value.

Specified by:
getPriority in interface Execution

getProcessDefinition

public PVMProcessDefinitionImpl getProcessDefinition()
Description copied from interface: OpenExecution
the process definition for this execution.

Specified by:
getProcessDefinition in interface OpenExecution

getTransition

public TransitionImpl getTransition()
Description copied from interface: ActivityExecution
the current transition indicating the position in the process definition graph. Can be null in case this execution is not taking a transition.

Specified by:
getTransition in interface ActivityExecution
Specified by:
getTransition in interface EventListenerExecution

setEvent

public void setEvent(EventImpl event)

setEventSource

public void setEventSource(ObservableElementImpl eventSource)

setPriority

public void setPriority(int priority)
Description copied from interface: ActivityExecution
setter for the priority. The default priority is 0, which means NORMAL. Other recognized named priorities are HIGHEST (2), HIGH (1), LOW (-1) and LOWEST (-2). For the rest, the user can set any other priority integer value, but then, the UI will have to display it as an integer and not the named value.

Specified by:
setPriority in interface ActivityExecution
Specified by:
setPriority in interface EventListenerExecution
Specified by:
setPriority in interface OpenExecution

setTransition

public void setTransition(TransitionImpl transition)

getPreviousNode

public Node getPreviousNode()
Description copied from interface: ActivityExecution
returns the previously executed node only if Node.isPreviousNeeded() is set to true.

Specified by:
getPreviousNode in interface ActivityExecution

getPreviousTransition

public Transition getPreviousTransition()
Description copied from interface: ActivityExecution
returns the previously taken transition only if Node.isPreviousNeeded() is set to true.

Specified by:
getPreviousTransition in interface ActivityExecution

getProcessInstance

public ExecutionImpl getProcessInstance()
Description copied from interface: OpenExecution
the main path of execution in the execution structure. Null will be returned in case this execution itself is the main execution path.

Specified by:
getProcessInstance in interface OpenExecution

setProcessInstance

public void setProcessInstance(ExecutionImpl processInstance)

setComments

public void setComments(java.util.Set<CommentImpl> comments)

getTransitionOrigin

public NodeImpl getTransitionOrigin()

setTransitionOrigin

public void setTransitionOrigin(NodeImpl transitionOrigin)

getException

public java.lang.Exception getException()
Description copied from interface: EventListenerExecution
the exception in case an exception handler is handling an exception.

Specified by:
getException in interface EventListenerExecution

setException

public void setException(java.lang.Exception exception)

getProcessModifications

public ProcessModificationsImpl getProcessModifications()

setProcessModifications

public void setProcessModifications(ProcessModificationsImpl processModifications)

getKey

public java.lang.String getKey()
Description copied from interface: Execution
the optional user provided business key that is unique within one process definition. This could be for instance the order number. It's a user defined identifier for one execution within the scope of a single process definition.

Specified by:
getKey in interface Execution

getPropagation

public ExecutionImpl.Propagation getPropagation()

setPropagation

public void setPropagation(ExecutionImpl.Propagation propagation)

setName

public void setName(java.lang.String name)

setState

public void setState(java.lang.String state)

setExecutions

public void setExecutions(java.util.Collection<ExecutionImpl> executions)

setParent

public void setParent(ExecutionImpl parent)

setPreviousNode

public void setPreviousNode(Node previousNode)

setPreviousTransition

public void setPreviousTransition(Transition previousTransition)

setProcessDefinition

public void setProcessDefinition(PVMProcessDefinitionImpl processDefinition)

getSuperProcessExecution

public ExecutionImpl getSuperProcessExecution()

setSuperProcessExecution

public void setSuperProcessExecution(ExecutionImpl superProcessExecution)

getSubProcessInstance

public ExecutionImpl getSubProcessInstance()
Description copied from interface: OpenExecution
the related sub process execution.

Specified by:
getSubProcessInstance in interface OpenExecution

setSubProcessInstance

public void setSubProcessInstance(ExecutionImpl subProcessExecution)

getNode

public NodeImpl getNode()
Description copied from interface: OpenExecution
the current node

Specified by:
getNode in interface OpenExecution

setNode

public void setNode(NodeImpl node)

getDbid

public long getDbid()
Specified by:
getDbid in interface Execution

setKey

public void setKey(java.lang.String key)

getId

public java.lang.String getId()
Description copied from interface: Execution
a globally unique identifier for this execution.

Specified by:
getId in interface Execution

setId

public void setId(java.lang.String id)


Copyright © 2009 OW2 Consortium. All Rights Reserved.