org.jbpm.graph.exe
Class Token

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

public class Token
extends Object
implements Identifiable, 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  Map children
           
protected  List comments
           
protected  Date end
           
protected  String name
           
protected  int nextLogIndex
           
protected  Node node
           
protected  Date nodeEnter
           
protected  Token parent
           
protected  ProcessInstance processInstance
           
protected  Date start
           
protected  ProcessInstance subProcessInstance
           
 
Constructor Summary
Token()
           
Token(ProcessInstance processInstance)
          creates a root token.
Token(Token parent, String name)
          creates a child token.
 
Method Summary
 void addComment(Comment comment)
           
 void addComment(String message)
           
 void addLog(ProcessLog processLog)
          convenience method for adding a process log.
 void checkImplicitTermination()
           
 void collectChildrenRecursively(List tokens)
           
 ProcessInstance createSubProcessInstance(ProcessDefinition subProcessDefinition)
           
 void end()
          ends this token and all of its children (if any).
 void end(boolean verifyParentTermination)
          ends this token with optional parent ending verification.
 void endCompositeLog()
          convenience method for ending a composite log.
 boolean equals(Object o)
           
 Token findToken(String relativeTokenPath)
           
 void forceUnlock()
          force unlocking the token, even if the owner is not known.
 void foreUnlock()
          Deprecated. Use forceUnlock() instead
 Map getActiveChildren()
           
 Set getAvailableTransitions()
          a set of all the leaving transitions on the current node for which the condition expression resolves to true.
 Token getChild(String name)
           
 Map getChildren()
           
 List getChildrenAtNode(Node aNode)
           
 List getComments()
           
 Date getEnd()
           
 String getFullName()
           
 long getId()
           
 String getLockOwner()
          return the current lock owner of the token
 String getName()
           
 Node getNode()
           
 Date getNodeEnter()
           
 Token getParent()
           
 ProcessInstance getProcessInstance()
           
 Date getStart()
           
 ProcessInstance getSubProcessInstance()
           
 boolean hasActiveChildren()
          tells if this token has child tokens that have not yet ended.
 boolean hasChild(String name)
           
 boolean hasEnded()
           
 int hashCode()
           
 boolean hasParent()
           
 boolean isAbleToReactivateParent()
           
 boolean isLocked()
           
 boolean isRoot()
           
 boolean isSuspended()
           
 boolean isTerminatedImplicitly()
           
 boolean isTerminationImplicit()
           
 void lock(String lockOwner)
          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(Date nodeEnter)
           
 void setParent(Token parent)
           
 void setProcessInstance(ProcessInstance processInstance)
           
 void setSubProcessInstance(ProcessInstance subProcessInstance)
           
 void setTerminationImplicit(boolean isTerminationImplicit)
           
 void signal()
          sends a signal to this token.
 void signal(String transitionName)
          sends a signal to this token.
 void signal(Transition transition)
          sends a signal to this token.
 void startCompositeLog(CompositeLog compositeLog)
          convenience method for starting a composite log.
 void suspend()
          suspends a process execution.
 String toString()
           
 void unlock(String lockOwner)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

start

protected Date start

end

protected Date end

node

protected Node node

nodeEnter

protected Date nodeEnter

processInstance

protected ProcessInstance processInstance

parent

protected Token parent

children

protected Map children

comments

protected 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,
             String name)
creates a child token.

Method Detail

signal

public void signal()
sends a signal to this token. leaves the current node over the default transition.


signal

public void signal(String transitionName)
sends a signal to this token. leaves the current node over the transition with the given name.


signal

public void signal(Transition transition)
sends a signal to this token. leaves the current node over the given transition.


getAvailableTransitions

public 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 (i.e. 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(String message)

addComment

public void addComment(Comment comment)

getComments

public 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(String name)

getChild

public Token getChild(String name)

getFullName

public String getFullName()

getChildrenAtNode

public List getChildrenAtNode(Node aNode)

collectChildrenRecursively

public void collectChildrenRecursively(List tokens)

findToken

public Token findToken(String relativeTokenPath)

getActiveChildren

public 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(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

createSubProcessInstance

public ProcessInstance createSubProcessInstance(ProcessDefinition subProcessDefinition)

lock

public void lock(String lockOwner)
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(String lockOwner)
See Also:
lock(String)

foreUnlock

public void foreUnlock()
Deprecated. Use forceUnlock() instead

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 Also:
JBPM-1888

forceUnlock

public void forceUnlock()
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 Also:
JBPM-1888

getLockOwner

public String getLockOwner()
return the current lock owner of the token

See Also:
JBPM-1888

isLocked

public boolean isLocked()

getId

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

getStart

public Date getStart()

getEnd

public Date getEnd()

getName

public String getName()

getProcessInstance

public ProcessInstance getProcessInstance()

getChildren

public 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 Date getNodeEnter()

setNodeEnter

public void setNodeEnter(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 © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.