org.jbpm.graph.exe
Class Token

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

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

represents one path of execution and maintains a pointer to a node in the ProcessDefinition. Most common way to get a hold of the token objects is with ProcessInstance.getRootToken() or ProcessInstance.findToken(String).

See Also:
Serialized Form

Field Summary
protected  java.util.Map children
           
protected  java.util.List comments
           
protected  java.util.Date end
           
protected  java.lang.String name
           
protected  int nextLogIndex
           
protected  Node node
           
protected  java.util.Date nodeEnter
           
protected  Token parent
           
protected  ProcessInstance processInstance
           
protected  java.util.Date start
           
protected  ProcessInstance subProcessInstance
           
 
Constructor Summary
Token()
           
Token(ProcessInstance processInstance)
          creates a root token.
Token(Token parent, java.lang.String name)
          creates a child token.
 
Method Summary
 void addComment(Comment comment)
           
 void addComment(java.lang.String message)
           
 void addLog(ProcessLog processLog)
          convenience method for adding a process log.
 void checkImplicitTermination()
           
 void collectChildrenRecursively(java.util.List tokens)
           
 ProcessInstance createSubProcessInstance(ProcessDefinition subProcessDefinition)
           
 void end()
          ends this token and all of its children (if any). this is the last active (=not-ended) child of a parent token, the parent token will be ended as well and that verification will continue to propagate.
 void end(boolean verifyParentTermination)
          ends this token with optional parent ending verification.
 void endCompositeLog()
          convenience method for ending a composite log.
 boolean equals(java.lang.Object o)
           
 Token findToken(java.lang.String relativeTokenPath)
           
 void foreUnlock()
          force unlocking the token, even if the owner is not known.
 java.util.Map getActiveChildren()
           
 java.util.Set getAvailableTransitions()
          a set of all the leaving transitions on the current node for which the condition expression resolves to true.
 Token getChild(java.lang.String name)
           
 java.util.Map getChildren()
           
 java.util.List getChildrenAtNode(Node aNode)
           
 java.util.List getComments()
           
 java.util.Date getEnd()
           
 java.lang.String getFullName()
           
 long getId()
           
 java.lang.String getLockOwner()
          return the current lock owner of the token See https://jira.jboss.org/jira/browse/JBPM-1888
 java.lang.String getName()
           
 Node getNode()
           
 java.util.Date getNodeEnter()
           
 Token getParent()
           
 ProcessInstance getProcessInstance()
           
 java.util.Date getStart()
           
 ProcessInstance getSubProcessInstance()
           
 boolean hasActiveChildren()
          tells if this token has child tokens that have not yet ended.
 boolean hasChild(java.lang.String name)
           
 boolean hasEnded()
           
 int hashCode()
           
 boolean hasParent()
           
 boolean isAbleToReactivateParent()
           
 boolean isLocked()
           
 boolean isRoot()
           
 boolean isSuspended()
           
 boolean isTerminatedImplicitly()
           
 boolean isTerminationImplicit()
           
 void lock(java.lang.String lockOwnerId)
          locks a process instance for further execution.
 int nextLogIndex()
           
 void resume()
          resumes a process execution.
 void setAbleToReactivateParent(boolean isAbleToReactivateParent)
           
 void setNode(Node node)
           
 void setNodeEnter(java.util.Date nodeEnter)
           
 void setParent(Token parent)
           
 void setProcessInstance(ProcessInstance processInstance)
           
 void setSubProcessInstance(ProcessInstance subProcessInstance)
           
 void setTerminationImplicit(boolean isTerminationImplicit)
           
 void signal()
          provides a signal to the token. this method activates this token and leaves the current state over the default transition.
 void signal(java.lang.String transitionName)
          Provides a signal to the token.
 void signal(Transition transition)
          provides a signal to the token. this leave the current state over the given transition name.
 void startCompositeLog(CompositeLog compositeLog)
          convenience method for starting a composite log.
 void suspend()
          suspends a process execution.
 java.lang.String toString()
           
 void unlock(java.lang.String lockOwnerId)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

start

protected java.util.Date start

end

protected java.util.Date end

node

protected Node node

nodeEnter

protected java.util.Date nodeEnter

processInstance

protected ProcessInstance processInstance

parent

protected Token parent

children

protected java.util.Map children

comments

protected java.util.List comments

subProcessInstance

protected ProcessInstance subProcessInstance

nextLogIndex

protected int nextLogIndex
Constructor Detail

Token

public Token()

Token

public Token(ProcessInstance processInstance)
creates a root token.


Token

public Token(Token parent,
             java.lang.String name)
creates a child token.

Method Detail

signal

public void signal()
provides a signal to the token. this method activates this token and leaves the current state over the default transition.


signal

public void signal(java.lang.String transitionName)
Provides a signal to the token. This leave the current state over the given transition name.


signal

public void signal(Transition transition)
provides a signal to the token. this leave the current state over the given transition name.


getAvailableTransitions

public java.util.Set getAvailableTransitions()
a set of all the leaving transitions on the current node for which the condition expression resolves to true.


end

public void end()
ends this token and all of its children (if any). this is the last active (=not-ended) child of a parent token, the parent token will be ended as well and that verification will continue to propagate.


end

public void end(boolean verifyParentTermination)
ends this token with optional parent ending verification.

Parameters:
verifyParentTermination - specifies if the parent token should be checked for termination. if verifyParentTermination is set to true and this is the last non-ended child of a parent token, the parent token will be ended as well and the verification will continue to propagate.

addComment

public void addComment(java.lang.String message)

addComment

public void addComment(Comment comment)

getComments

public java.util.List getComments()

hasActiveChildren

public boolean hasActiveChildren()
tells if this token has child tokens that have not yet ended.


addLog

public void addLog(ProcessLog processLog)
convenience method for adding a process log.


startCompositeLog

public void startCompositeLog(CompositeLog compositeLog)
convenience method for starting a composite log. When you add composite logs, make sure you put the endCompositeLog() in a finally block.


endCompositeLog

public void endCompositeLog()
convenience method for ending a composite log. Make sure you put this in a finally block.


hasEnded

public boolean hasEnded()

isRoot

public boolean isRoot()

hasParent

public boolean hasParent()

hasChild

public boolean hasChild(java.lang.String name)

getChild

public Token getChild(java.lang.String name)

getFullName

public java.lang.String getFullName()

getChildrenAtNode

public java.util.List getChildrenAtNode(Node aNode)

collectChildrenRecursively

public void collectChildrenRecursively(java.util.List tokens)

findToken

public Token findToken(java.lang.String relativeTokenPath)

getActiveChildren

public java.util.Map getActiveChildren()

checkImplicitTermination

public void checkImplicitTermination()

isTerminatedImplicitly

public boolean isTerminatedImplicitly()

nextLogIndex

public int nextLogIndex()

suspend

public void suspend()
suspends a process execution.


resume

public void resume()
resumes a process execution.


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

createSubProcessInstance

public ProcessInstance createSubProcessInstance(ProcessDefinition subProcessDefinition)

lock

public void lock(java.lang.String lockOwnerId)
locks a process instance for further execution. A locked token cannot continue execution. This is a non-persistent operation. This is used to prevent tokens being propagated during the execution of actions.

See Also:
unlock(String)

unlock

public void unlock(java.lang.String lockOwnerId)
See Also:
lock(String)

foreUnlock

public void foreUnlock()
force unlocking the token, even if the owner is not known. In some use cases (e.g. in the jbpm esb integration) the lock is persistent, so a state can be reached where the client needs a possibility to force unlock of a token without knowing the owner. See https://jira.jboss.org/jira/browse/JBPM-1888


getLockOwner

public java.lang.String getLockOwner()
return the current lock owner of the token See https://jira.jboss.org/jira/browse/JBPM-1888


isLocked

public boolean isLocked()

getId

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

getStart

public java.util.Date getStart()

getEnd

public java.util.Date getEnd()

getName

public java.lang.String getName()

getProcessInstance

public ProcessInstance getProcessInstance()

getChildren

public java.util.Map getChildren()

getNode

public Node getNode()

setNode

public void setNode(Node node)

getParent

public Token getParent()

setParent

public void setParent(Token parent)

setProcessInstance

public void setProcessInstance(ProcessInstance processInstance)

getSubProcessInstance

public ProcessInstance getSubProcessInstance()

getNodeEnter

public java.util.Date getNodeEnter()

setNodeEnter

public void setNodeEnter(java.util.Date nodeEnter)

isAbleToReactivateParent

public boolean isAbleToReactivateParent()

setAbleToReactivateParent

public void setAbleToReactivateParent(boolean isAbleToReactivateParent)

isTerminationImplicit

public boolean isTerminationImplicit()

setTerminationImplicit

public void setTerminationImplicit(boolean isTerminationImplicit)

isSuspended

public boolean isSuspended()

setSubProcessInstance

public void setSubProcessInstance(ProcessInstance subProcessInstance)


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