org.jbpm.pvm.impl
Class NodeImpl

java.lang.Object
  extended by org.jbpm.pvm.impl.ProcessElementImpl
      extended by org.jbpm.pvm.impl.ObservableElementImpl
          extended by org.jbpm.pvm.impl.CompositeElementImpl
              extended by org.jbpm.pvm.impl.NodeImpl
All Implemented Interfaces:
java.io.Serializable, CompositeElement, Node, ObservableElement, ProcessElement
Direct Known Subclasses:
ProcessModificationsImpl.AddedNode

public class NodeImpl
extends CompositeElementImpl
implements Node

Author:
Tom Baeyens
See Also:
Serialized Form

Field Summary
protected  ObjectReference<Activity> behaviourReference
           
protected  TransitionImpl defaultTransition
           
protected  java.util.List<TransitionImpl> incomingTransitions
           
protected  boolean isExecutionAsync
           
protected  boolean isLeaveAsync
           
protected  boolean isPreviousNeeded
           
protected  boolean isSignalAsync
           
protected  java.util.List<TransitionImpl> outgoingTransitions
           
protected  java.util.Map<java.lang.String,TransitionImpl> outgoingTransitionsMap
           
protected  NodeImpl parentNode
           
 
Fields inherited from class org.jbpm.pvm.impl.CompositeElementImpl
hasVariableDefinitions, nodes, nodesMap, variableDefinitions
 
Fields inherited from class org.jbpm.pvm.impl.ObservableElementImpl
description, events, name
 
Fields inherited from class org.jbpm.pvm.impl.ProcessElementImpl
dbid, dbversion, exceptionHandlers, processDefinition, properties
 
Fields inherited from interface org.jbpm.pvm.Node
EVENT_NODE_ENTER, EVENT_NODE_LEAVE
 
Constructor Summary
NodeImpl()
          Use CompositeElementImpl.createNode() or CompositeElementImpl.createNode() instead.
 
Method Summary
 Transition addIncomingTransition(TransitionImpl transition)
          adds the given transition as an arriving transition to this node.
 NodeImpl addNode(NodeImpl node)
           
 Transition addOutgoingTransition(TransitionImpl transition)
          adds the given transition as a leaving transition to this node.
 Transition createOutgoingTransition(NodeImpl destination)
          creates a transition from this node to the given destination node.
 TransitionImpl createOutgoingTransition(NodeImpl destination, java.lang.String transitionName)
          creates a transition with the given name from this node to the given destination node.
 TransitionImpl findDefaultTransition()
          searches for the default transition in this node and then up the parent chain.
 Node findNode(java.lang.String nodeName)
          searches for the given node in this node, including this node and all child nodes recursively.
 TransitionImpl findOutgoingTransition(java.lang.String transitionName)
          searches for the given transitionName in this node and then up the parent chain.
 Activity getBehaviour()
           
 ObjectReference<Activity> getBehaviourReference()
           
 TransitionImpl getDefaultTransition()
          the default outgoing transition.
 java.util.List<Transition> getIncomingTransitions()
          the list of arriving transitions.
 java.lang.String getName()
          the short display name given to this element.
 TransitionImpl getOutgoingTransition(java.lang.String transitionName)
          the first leaving transition with the given name or null of no such leaving transition exists.
 java.util.List<Transition> getOutgoingTransitions()
          the list of leaving transitions.
 java.util.Map<java.lang.String,Transition> getOutgoingTransitionsMap()
          the leaving transitions, keyed by transition name.
 ObservableElementImpl getParent()
          by default, this implementation returns null, but this is overwritten in Node and Transition to represent the parent in the hierarchical structure of the process.
 java.util.List<ObservableElementImpl> getParentChain()
          collects the full stack of parent in a list.
 NodeImpl getParentNode()
          retrieve the parent node in the composite node structure.
 boolean hasIncomingTransitions()
          indicates if this node has arriving transitions
 boolean hasOutgoingTransition(java.lang.String transitionName)
          indicates if a leaving transition with the given transitionName exists.
 boolean hasOutgoingTransitions()
          indicates if this node has leaving transitions
 boolean isExecutionAsync()
          indicates if this node should be executed asynchronously.
 boolean isLeaveAsync()
          indicates if execution should proceed asynchronously when this node is left over any of the outgoing transitions.
 boolean isPreviousNeeded()
          indicates if this node behaviour needs to know the previous node or previous transition.
 boolean isSignalAsync()
          indicates if signals should be processed asynchronously.
 boolean removeIncomingTransition(TransitionImpl transition)
          removes the given transition if it is contained in the arriving transitions of this node.
 boolean removeOutgoingTransition(TransitionImpl transition)
          removes the given transition from the leaving transitions.
 void setBehaviour(Activity activity)
          sets the given activity as the behaviour for this node.
 void setBehaviour(Descriptor descriptor)
          sets the activity that can be created from the given descriptor as the behaviour for this node.
 void setBehaviour(java.lang.String expression)
          sets the expression behaviour for this node.
 void setBehaviourReference(ObjectReference<Activity> behaviourReference)
           
 void setDefaultTransition(TransitionImpl defaultTransition)
           
 void setExecutionAsync(boolean isExecutionAsync)
           
 void setIncomingTransitions(java.util.List<TransitionImpl> incomingTransitions)
          sets the incomingTransitions to the given list of incomingTransitions.
 void setLeaveAsync(boolean isLeaveAsync)
           
 void setName(java.lang.String name)
           
 void setOutgoingTransitions(java.util.List<TransitionImpl> outgoingTransitions)
          sets the outgoingTransitions to the given list of outgoingTransitions.
 void setParentNode(NodeImpl parentNode)
           
 void setPreviousNeeded(boolean isPreviousNeeded)
           
 void setSignalAsync(boolean isSignalAsync)
           
 java.lang.String toString()
           
 
Methods inherited from class org.jbpm.pvm.impl.CompositeElementImpl
createNode, createNode, getNode, getNodes, getNodesMap, getVariableDefinitions, hasNode, hasNodes, removeNode, setVariableDefinitions
 
Methods inherited from class org.jbpm.pvm.impl.ObservableElementImpl
addEvent, createEvent, getDescription, getEvent, getEvents, hasEvent, setDescription, setEvents
 
Methods inherited from class org.jbpm.pvm.impl.ProcessElementImpl
addExceptionHandler, addProperty, createExceptionHandler, getDbid, getExceptionHandlers, getProcessDefinition, getProperties, getProperty, getPropertyKeys, setExceptionHandlers, setProcessDefinition, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jbpm.pvm.Node
getVariableDefinitions
 
Methods inherited from interface org.jbpm.pvm.CompositeElement
getNode, getNodes, getNodesMap, hasNode, hasNodes
 
Methods inherited from interface org.jbpm.pvm.ObservableElement
getDescription, getEvent, getEvents, hasEvent
 
Methods inherited from interface org.jbpm.pvm.ProcessElement
getDbid, getExceptionHandlers, getProcessDefinition, getProperty, getPropertyKeys
 

Field Detail

behaviourReference

protected ObjectReference<Activity> behaviourReference

outgoingTransitions

protected java.util.List<TransitionImpl> outgoingTransitions

incomingTransitions

protected java.util.List<TransitionImpl> incomingTransitions

defaultTransition

protected TransitionImpl defaultTransition

parentNode

protected NodeImpl parentNode

isExecutionAsync

protected boolean isExecutionAsync

isSignalAsync

protected boolean isSignalAsync

isLeaveAsync

protected boolean isLeaveAsync

isPreviousNeeded

protected boolean isPreviousNeeded

outgoingTransitionsMap

protected transient java.util.Map<java.lang.String,TransitionImpl> outgoingTransitionsMap
Constructor Detail

NodeImpl

public NodeImpl()
Use CompositeElementImpl.createNode() or CompositeElementImpl.createNode() instead.

Method Detail

addNode

public NodeImpl addNode(NodeImpl node)
Overrides:
addNode in class CompositeElementImpl

findNode

public Node findNode(java.lang.String nodeName)
Description copied from interface: CompositeElement
searches for the given node in this node, including this node and all child nodes recursively. The search is done depth-first. A null value for nodeName matches a node without a name.

Specified by:
findNode in interface CompositeElement
Overrides:
findNode in class CompositeElementImpl

createOutgoingTransition

public Transition createOutgoingTransition(NodeImpl destination)
creates a transition from this node to the given destination node. Also the transition pointers to source and destination node will be set appropriatly.

Throws:
java.lang.NullPointerException - if destination is null.

createOutgoingTransition

public TransitionImpl createOutgoingTransition(NodeImpl destination,
                                               java.lang.String transitionName)
creates a transition with the given name from this node to the given destination node. Also the transition pointers to source and destination node will be set appropriatly.

Parameters:
transitionName - may be null.
Throws:
java.lang.NullPointerException - if destination is null.

addOutgoingTransition

public Transition addOutgoingTransition(TransitionImpl transition)
adds the given transition as a leaving transition to this node. Also the source of the transition is set to this node. Adding a transition that is already contained in the leaving transitions has no effect.

Returns:
the added transition.
Throws:
java.lang.NullPointerException - if transition is null.

removeOutgoingTransition

public boolean removeOutgoingTransition(TransitionImpl transition)
removes the given transition from the leaving transitions. Also the transition's source will be nulled. This method will do nothing if the transition is null or if the given transition is not in the list of this node's leaving transitions. In case this is the transition that was in the outgoingTransitionsMap and another transition exists with the same name, that transition (the first) will be put in the outgoingTransitionsMap as a replacement for the removed transition. If the transition is actually removed from the list of leaving transitions, the transition's source will be nulled.


getOutgoingTransition

public TransitionImpl getOutgoingTransition(java.lang.String transitionName)
the first leaving transition with the given name or null of no such leaving transition exists.

Specified by:
getOutgoingTransition in interface Node
Parameters:
transitionName - is the name of the transition to take. A null value will match the first unnamed transition.

findOutgoingTransition

public TransitionImpl findOutgoingTransition(java.lang.String transitionName)
searches for the given transitionName in this node and then up the parent chain. Returns null if no such transition is found.

Specified by:
findOutgoingTransition in interface Node

findDefaultTransition

public TransitionImpl findDefaultTransition()
searches for the default transition in this node and then up the parent chain. Returns null if no such transition is found.


getOutgoingTransitions

public java.util.List<Transition> getOutgoingTransitions()
the list of leaving transitions. Beware: the actual member is returned. No copy is made.

Specified by:
getOutgoingTransitions in interface Node

hasOutgoingTransition

public boolean hasOutgoingTransition(java.lang.String transitionName)
indicates if a leaving transition with the given transitionName exists.

Specified by:
hasOutgoingTransition in interface Node

hasOutgoingTransitions

public boolean hasOutgoingTransitions()
indicates if this node has leaving transitions

Specified by:
hasOutgoingTransitions in interface Node

setOutgoingTransitions

public void setOutgoingTransitions(java.util.List<TransitionImpl> outgoingTransitions)
sets the outgoingTransitions to the given list of outgoingTransitions. A copy of the collection is made. Also the outgoingTransitionsMap will be updated and the source of all the transitions in the given list will be set to this node. In case there was a leaving transitions list present, these transition's source will be nulled.


getOutgoingTransitionsMap

public java.util.Map<java.lang.String,Transition> getOutgoingTransitionsMap()
the leaving transitions, keyed by transition name. If a transition with the same name occurs mutltiple times, the first one is returned. Leaving transitions with a null value for their name are not included in the map. Beware: the actual member is returned. No copy is made.

Specified by:
getOutgoingTransitionsMap in interface Node

addIncomingTransition

public Transition addIncomingTransition(TransitionImpl transition)
adds the given transition as an arriving transition to this node. Also the source of the transition is set to this node.

Returns:
the added transition.
Throws:
java.lang.NullPointerException - if transition is null.

removeIncomingTransition

public boolean removeIncomingTransition(TransitionImpl transition)
removes the given transition if it is contained in the arriving transitions of this node. If this transition was actually removed, its destination pointer is nulled.

Returns:
true if a transition was removed.

getIncomingTransitions

public java.util.List<Transition> getIncomingTransitions()
the list of arriving transitions. Beware: the actual member is returned. No copy is made.

Specified by:
getIncomingTransitions in interface Node

hasIncomingTransitions

public boolean hasIncomingTransitions()
indicates if this node has arriving transitions

Specified by:
hasIncomingTransitions in interface Node

setIncomingTransitions

public void setIncomingTransitions(java.util.List<TransitionImpl> incomingTransitions)
sets the incomingTransitions to the given list of incomingTransitions. A copy of the collection is made. Also the destination of all the transitions in the given list will be set to this node. In case there was an arriving transitions list present, these transition's destination will be nulled.


setBehaviour

public void setBehaviour(Activity activity)
sets the given activity as the behaviour for this node. An object reference for the given activity is created.


setBehaviour

public void setBehaviour(Descriptor descriptor)
sets the activity that can be created from the given descriptor as the behaviour for this node. It is assumed that the descriptor will create an Activity An object reference for the given descriptor is created.


setBehaviour

public void setBehaviour(java.lang.String expression)
sets the expression behaviour for this node. The evaluation of the expression will replace the Activity's execute method. An object reference for the given descriptor is created.


getBehaviourReference

public ObjectReference<Activity> getBehaviourReference()

setBehaviourReference

public void setBehaviourReference(ObjectReference<Activity> behaviourReference)

getBehaviour

public Activity getBehaviour()

toString

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

getParentChain

public java.util.List<ObservableElementImpl> getParentChain()
collects the full stack of parent in a list. This node is the first element in the chain. The process definition will be the last element. the chain will never be null.


getParent

public ObservableElementImpl getParent()
Description copied from interface: ObservableElement
by default, this implementation returns null, but this is overwritten in Node and Transition to represent the parent in the hierarchical structure of the process. This hierarchical structure is used for event propagation.

Specified by:
getParent in interface ObservableElement
Overrides:
getParent in class ObservableElementImpl

getName

public java.lang.String getName()
Description copied from interface: ObservableElement
the short display name given to this element.

Specified by:
getName in interface ObservableElement
Overrides:
getName in class ObservableElementImpl

setName

public void setName(java.lang.String name)
Overrides:
setName in class ObservableElementImpl

getDefaultTransition

public TransitionImpl getDefaultTransition()
Description copied from interface: Node
the default outgoing transition.

Specified by:
getDefaultTransition in interface Node

setDefaultTransition

public void setDefaultTransition(TransitionImpl defaultTransition)

getParentNode

public NodeImpl getParentNode()
Description copied from interface: Node
retrieve the parent node in the composite node structure. This is different from ObservableElement.getParent() in that it is restricted to the parent nodes. It doesn't take into account the process definition.

Specified by:
getParentNode in interface Node

setParentNode

public void setParentNode(NodeImpl parentNode)

isExecutionAsync

public boolean isExecutionAsync()
Description copied from interface: Node
indicates if this node should be executed asynchronously.

Specified by:
isExecutionAsync in interface Node

isSignalAsync

public boolean isSignalAsync()
Description copied from interface: Node
indicates if signals should be processed asynchronously.

Specified by:
isSignalAsync in interface Node

setSignalAsync

public void setSignalAsync(boolean isSignalAsync)

setExecutionAsync

public void setExecutionAsync(boolean isExecutionAsync)

isLeaveAsync

public boolean isLeaveAsync()
Description copied from interface: Node
indicates if execution should proceed asynchronously when this node is left over any of the outgoing transitions.

Specified by:
isLeaveAsync in interface Node

setLeaveAsync

public void setLeaveAsync(boolean isLeaveAsync)

isPreviousNeeded

public boolean isPreviousNeeded()
Description copied from interface: Node
indicates if this node behaviour needs to know the previous node or previous transition. If this property is set to true, the properties Execution.getPreviousNode() and Execution.getPreviousTransition() will be available to the node behaviour when it is executed or signalled.

Specified by:
isPreviousNeeded in interface Node

setPreviousNeeded

public void setPreviousNeeded(boolean isPreviousNeeded)