1 package org.jbpm.graph.node; 2 import org.jbpm.graph.def.*; 3 import org.jbpm.graph.exe.ExecutionContext; 4 import org.jbpm.graph.exe.Token; 5 import org.jbpm.jpdl.exe.*; 6 7 public class MilestoneNode extends Node { 8 9 private static final long serialVersionUID = 1L; 10 11 private String tokenPath = "."; 12 13 public MilestoneNode() { 14 } 15 16 public MilestoneNode(String name) { 17 super(name); 18 } 19 20 public void execute(ExecutionContext executionContext) { 21 Token token = executionContext.getToken(); 22 Token milestoneToken = token.findToken( tokenPath ); 24 if ( isMilestoneReached( name, milestoneToken ) ) { 25 26 token.getNode().leave(executionContext); 28 29 } else { 30 addMilestoneListener(name,milestoneToken); 31 } 32 } 33 34 public boolean isMilestoneReached(String milestoneName, Token token) { 35 MilestoneInstance mi = MilestoneInstance.getMilestoneInstance(milestoneName, token); 36 return (mi != null ? mi.isReached() : false); 37 } 38 39 public void addMilestoneListener(String milestoneName, Token token) { 40 MilestoneInstance mi = MilestoneInstance.getMilestoneInstance(milestoneName, token); 41 mi.addListener(token); 42 } 43 44 45 public String getTokenPath() { 46 return tokenPath; 47 } 48 public void setTokenPath(String relativeTokenPath) { 49 this.tokenPath = relativeTokenPath; 50 } 51 } 52 | Popular Tags |