01: /*
02: * Created on Jan 22, 2004
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.xdev.base.xssl.bpm.flow;
08:
09: import java.util.HashMap;
10:
11: import org.xdev.base.xssl.XIterator;
12: import org.xdev.base.xssl.manage.ITransactionInterruptable;
13:
14: /**
15: * @author AYegorov
16: *
17: * To change the template for this generated type comment go to
18: * Window>Preferences>Java>Code Generation>Code and Comments
19: */
20: public class Loop extends XIterator implements
21: ITransactionInterruptable {
22: public static final String DELAY = "delay";
23:
24: private long loopDelay = 200;
25:
26: private boolean interrupted = false;
27:
28: /**
29: * @param id
30: */
31: public Loop(String id) {
32: super (id);
33: // XXX Auto-generated constructor stub
34: }
35:
36: /**
37: * @param id
38: * @param properties
39: */
40: public Loop(String id, HashMap properties) {
41: super (id, properties);
42: // XXX Auto-generated constructor stub
43: }
44:
45: protected void set() throws Exception {
46: try {
47: this .loopDelay = this .getLongProperty(Loop.DELAY);
48:
49: this .logDebug("Looping delay has been set to: "
50: + this .loopDelay);
51: } catch (Exception ex) {
52: }
53: }
54:
55: protected void invoke() throws Exception {
56: while (!interrupted) {
57: super .invoke();
58:
59: Thread.sleep(this .loopDelay);
60: }
61: }
62:
63: /* (non-Javadoc)
64: * @see org.xdev.base.xssl.manage.ITransactionInterruptable#interrupt()
65: */
66: public void interrupt() {
67: this .interrupted = true;
68: }
69:
70: public void reset() {
71:
72: this .interrupted = false;
73:
74: super.reset();
75: }
76: }
|