KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > exe > EventInstance


1 package org.jbpm.bpel.exe;
2
3 import org.jbpm.context.exe.ContextInstance;
4 import org.jbpm.graph.exe.Token;
5 import org.jbpm.bpel.exe.state.ActiveState;
6
7 /**
8  * @author Juan Cantú
9  * @version $Revision: 1.2 $ $Date: 2005/06/16 19:15:36 $
10  */

11 public class EventInstance extends ScopeInstance {
12
13   private static final long serialVersionUID = 1L;
14
15   protected EventInstance() {
16   }
17   
18   protected EventInstance(Token token) {
19     super(token);
20   }
21
22   public void notifyCompletion() {
23     //all the children are completed.
24
ScopeInstance parent = getParent();
25     
26     if(parent.getState().equals(ActiveState.EVENTS_PENDING)
27         && !ActiveState.EVENTS_PENDING.hasPendingEvents(parent)) {
28       //notify completion to parent if its waiting for events
29
parent.completed();
30     }
31   }
32   
33   public static ScopeInstance create(Token token) {
34     ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
35     EventInstance instance = new EventInstance(token);
36     //normal processing is initial state
37
instance.setState(ActiveState.NORMAL_PROCESSING);
38     contextInstance.createVariable(SCOPE_NAME, instance, token);
39     return instance;
40   }
41 }
Popular Tags