01: package org.jbpm.scheduler.ejbtimer;
02:
03: import java.io.Serializable;
04:
05: import org.jbpm.graph.exe.ProcessInstance;
06: import org.jbpm.graph.exe.Token;
07: import org.jbpm.job.Timer;
08:
09: public class TimerInfo implements Serializable {
10:
11: private static final long serialVersionUID = 1L;
12:
13: // DON'T CHANGE THE SERIALIZED COMPATIBILITY OF THIS CLASS LIGHTLY
14: // unlike command messages, timers will be in the timer db for a long time.
15: // when they fire, they should be deserializable !
16:
17: long timerId = -1;
18: String timerName;
19: long tokenId = -1;
20: long processInstanceId = -1;
21:
22: public TimerInfo(Timer timer) {
23: timerId = timer.getId();
24: timerName = timer.getName();
25: Token token = timer.getToken();
26: tokenId = (token != null ? token.getId() : -1);
27: ProcessInstance processInstance = timer.getProcessInstance();
28: processInstanceId = (processInstance != null ? processInstance
29: .getId() : -1);
30: }
31:
32: public long getProcessInstanceId() {
33: return processInstanceId;
34: }
35:
36: public long getTimerId() {
37: return timerId;
38: }
39:
40: public String getTimerName() {
41: return timerName;
42: }
43:
44: public long getTokenId() {
45: return tokenId;
46: }
47:
48: public boolean matchesName(String timerName, Token token) {
49: if ((this .timerName == null)
50: || (!this .timerName.equals(timerName))
51: || (this .tokenId == -1)
52: || (this .tokenId != token.getId())) {
53: return false;
54: }
55: return true;
56: }
57:
58: public boolean matchesProcessInstance(
59: ProcessInstance processInstance) {
60: if ((processInstanceId == -1) || (processInstance == null)
61: || (processInstanceId != processInstance.getId())) {
62: return false;
63: }
64: return true;
65: }
66: }
|