Event myEvent = new MyEvent(); Node node = ....; node.fireEvent(myEvent);
public String toString() { return "node["+node.getName()+"]"; } public long getDuration() {
/** * sends a signal to this token. leaves the current {@link #getNode() node} over the * transition with the given name. */ public void signal(String transitionName) { if (node == null) { throw new JbpmException(this + " is not positioned in a node"); } Transition leavingTransition = node.getLeavingTransition(transitionName); if (leavingTransition == null) { // fall back to target node name for (Iterator iter = node.getLeavingTransitions().iterator(); iter.hasNext();) { Transition transition = (Transition) iter.next(); if (transitionName.equals(transition.getTo().getName())) { leavingTransition = transition; break; } } if (leavingTransition == null) { throw new JbpmException(node + " has no leaving transition named " + transitionName); } } signal(leavingTransition, new ExecutionContext(this)); }
node.addLeavingTransition(transition); addWarning("node '" + node.getFullyQualifiedName() + "' has a transition without a 'to'-attribute"); NodeCollection parent = (NodeCollection) node.getParent(); Node to = parent.findNode(toName); if (to == null) { to.addArrivingTransition(transition);
/** @deprecated no use for this method */ public String getNameExt() { String name = getName(); if (name == null) name = "#anonymous" + getNodeType(); return name; }
/** * called by a transition to pass execution to this node. */ public void enter(ExecutionContext executionContext) { Token token = executionContext.getToken(); // update the runtime context information token.setNode(this); // register entrance time so that a node-log can be generated upon leaving token.setNodeEnter(Clock.getCurrentTime()); // fire the leave-node event for this node fireEvent(Event.EVENTTYPE_NODE_ENTER, executionContext); // remove the transition references from the runtime context executionContext.setTransition(null); executionContext.setTransitionSource(null); // execute the node if (isAsync) { ExecuteNodeJob job = createAsyncContinuationJob(token); executionContext.getJbpmContext().getServices().getMessageService().send(job); token.lock(job.toString()); } else { execute(executionContext); } }
/** * checks for the presence of a leaving transition with the given name. the leaving * transitions of the supernode are taken into account as well. * * @return true if this node has a leaving transition with the given name, false otherwise. */ public boolean hasLeavingTransition(String transitionName) { return getLeavingTransition(transitionName) != null; }
private void writeTransitions(Element element, org.jbpm.graph.def.Node node) { if (node.getLeavingTransitionsMap() != null) { for (Iterator iter = node.getLeavingTransitionsList().iterator(); iter.hasNext();) { Transition transition = (Transition) iter.next(); writeTransition(element.addElement("transition"), transition); } } }
/** * called by the implementation of this node to continue execution over the specified * transition. */ public void leave(ExecutionContext executionContext, String transitionName) { Transition transition = getLeavingTransition(transitionName); if (transition == null) throw new JbpmException("no such transition: " + transitionName); leave(executionContext, transition); }
public void setName(String name) { if (from != null) { if (from.hasLeavingTransition(name)) { throw new IllegalArgumentException("cannot rename " + this + " because " + from + " already has a transition named " + name); } Map fromLeavingTransitions = from.getLeavingTransitionsMap(); fromLeavingTransitions.put(name, this); } this.name = name; }
public static void addNodesAndTransitions(ProcessDefinition pd, String[] nodes, String[] transitions) { for ( int i = 0; i < nodes.length; i++ ) { pd.addNode( createNode( nodes[i] ) ); } for ( int i = 0; i < transitions.length; i++ ) { String[] parsedTransition = cutTransitionText( transitions[i] ); Node from = pd.getNode( parsedTransition[0] ); Node to = pd.getNode( parsedTransition[2] ); Transition t = new Transition( parsedTransition[1] ); t.setProcessDefinition(pd); from.addLeavingTransition(t); to.addArrivingTransition(t); } }
/** * called by the implementation of this node to continue execution over the given transition. */ public void leave(ExecutionContext executionContext, Transition transition) { if (transition == null) throw new JbpmException("transition is null"); Token token = executionContext.getToken(); token.setNode(this); executionContext.setTransition(transition); // fire the leave-node event for this node fireEvent(Event.EVENTTYPE_NODE_LEAVE, executionContext); // log this node if (token.getNodeEnter() != null) { addNodeLog(token); } // update the runtime information for taking the transition // the transitionSource is used to calculate events on superstates executionContext.setTransitionSource(this); // take the transition transition.take(executionContext); }
node.setProcessDefinition(processDefinition); node.read(nodeElement, this);
protected Collection getTransitionNames(Token token) { Node node = token.getNode(); return node.getLeavingTransitionsMap().keySet(); }
public Transition addLeavingTransition(Transition leavingTransition) { // since the decision node evaluates transition conditions, // the condition of the leaving transition will always be met. // hence the condition enforcement can be disabled safely leavingTransition.setConditionEnforced(false); return super.addLeavingTransition(leavingTransition); }
public void read(Element pageElement, JpdlXmlReader jpdlXmlReader) super.read(pageElement, jpdlXmlReader); viewId = pageElement.attributeValue("view-id"); if (viewId==null)
/** * generates a new name for a transition that will be added as a leaving transition. */ public String generateNextLeavingTransitionName() { String name = null; if (leavingTransitions != null && containsName(leavingTransitions, null)) { int n = 1; while (containsName(leavingTransitions, Integer.toString(n))) n++; name = Integer.toString(n); } return name; }
/** * sends a signal to this token. leaves the current {@link #getNode() node} over the * transition with the given name. */ public void signal(String transitionName) { if (node == null) { throw new JbpmException(this + " is not positioned in a node"); } Transition leavingTransition = node.getLeavingTransition(transitionName); if (leavingTransition == null) { // fall back to target node name for (Iterator iter = node.getLeavingTransitions().iterator(); iter.hasNext();) { Transition transition = (Transition) iter.next(); if (transitionName.equals(transition.getTo().getName())) { leavingTransition = transition; break; } } if (leavingTransition == null) { throw new JbpmException(node + " has no leaving transition named " + transitionName); } } signal(leavingTransition, new ExecutionContext(this)); }