KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > scheduler > exe > SchedulerInstance


1 package org.jbpm.scheduler.exe;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import org.jbpm.graph.exe.ProcessInstance;
7 import org.jbpm.graph.exe.Token;
8 import org.jbpm.module.exe.ModuleInstance;
9
10 /**
11  * process instance extension for scheduling and cancalling timers.
12  */

13 public class SchedulerInstance extends ModuleInstance {
14
15   private static final long serialVersionUID = 1L;
16
17   private boolean isProcessEnded = false;
18   private List JavaDoc scheduledTimers = new ArrayList JavaDoc();
19   private List JavaDoc cancelledTimerNames = new ArrayList JavaDoc();
20   
21   public SchedulerInstance() {
22   }
23
24   public SchedulerInstance(ProcessInstance processInstance) {
25     setProcessInstance(processInstance);
26   }
27
28   /**
29    * schedules a timer.
30    */

31   public void schedule( Timer timer ) {
32     scheduledTimers.add(timer);
33   }
34   
35   public static class CancelledTimer {
36     String JavaDoc timerName;
37     Token token;
38     public CancelledTimer(String JavaDoc timerName, Token token) {
39       this.timerName = timerName;
40       this.token = token;
41     }
42     public String JavaDoc getTimerName() {
43       return timerName;
44     }
45     public Token getToken() {
46       return token;
47     }
48   }
49
50   /**
51    * cancels all scheduled timers with the given name.
52    */

53   public void cancel(String JavaDoc timerName, Token token) {
54     cancelledTimerNames.add(new CancelledTimer(timerName, token));
55   }
56
57   public List JavaDoc getScheduledTimers() {
58     return scheduledTimers;
59   }
60   
61   public List JavaDoc getCancelledTimerNames() {
62     return cancelledTimerNames;
63   }
64   public boolean isProcessEnded() {
65     return isProcessEnded;
66   }
67   public void setProcessEnded(boolean isProcessEnded) {
68     this.isProcessEnded = isProcessEnded;
69   }
70 }
71
Popular Tags