01: package com.knowgate.scheduler;
02:
03: /**
04: * <p>Get information about what is happening inside each WorkerThread</p>
05: * This an abstract base class than must be inherited in order to provide the
06: * implementation for the call() method.
07: * @author Sergio Montoro Ten
08: * @version 1.0
09: */
10:
11: public abstract class WorkerThreadCallback {
12: private String sName;
13:
14: /**
15: * @param sCallbackName Each callback instance must have a unique name
16: */
17: public WorkerThreadCallback(String sCallbackName) {
18: sName = sCallbackName;
19: }
20:
21: /**
22: * @return Callback instance name
23: */
24: public String name() {
25: return sName;
26: }
27:
28: /**
29: * <p>Provide information about thread execution milestones</p>
30: * @param sThreadId String identifying the caller WorkerThread
31: * @param iOpCode Operation code (see static constants)
32: * @param sMessage Descriptive message
33: * @param oXcpt Exception thrown by WorkerThread.<br>
34: * This parameter is always null unless iOpCode is WT_EXCEPTION
35: * @param oParam Object related to operation.<br>
36: * Its class depends on the operation performed.<br>
37: */
38: public abstract void call(String sThreadId, int iOpCode,
39: String sMessage, Exception oXcpt, Object oParam);
40:
41: /**
42: * <p>Thread throwed and Exception</p>
43: * <p>The throwed Exception will be in the 4th parameter of call() method</p>
44: */
45: public static final int WT_EXCEPTION = -1;
46:
47: /**
48: * <p>Thread instantiated a Job subclass</p>
49: * <p>A reference to the instantiated Job will be in the 5th parameter of call() method</p>
50: */
51: public static final int WT_JOB_INSTANTIATE = 1;
52:
53: /**
54: * <p>Thread finished a Job execution</p>
55: * <p>A reference to the finished Job will be in the 5th parameter of call() method</p>
56: */
57: public static final int WT_JOB_FINISH = 2;
58:
59: /**
60: * <p>AtomConsumer for thread found no more pending Atoms</p>
61: * <p>A reference to the AtomConsumer will be in the 5th parameter of call() method</p>
62: */
63: public static final int WT_ATOMCONSUMER_NOMORE = 3;
64:
65: /**
66: * <p>Thread just got an Atom for its inmediate consumption.</p>
67: * <p>Called before Atom is consumed.</p>
68: * <p>A reference to the Atom will be in the 5th parameter of call() method</p>
69: */
70: public static final int WT_ATOM_GET = 4;
71:
72: /**
73: * <p>Thread consumed an Atom.</p>
74: * <p>Called after Atom is consumed.</p>
75: * <p>A reference to the Atom will be in the 5th parameter of call() method</p>
76: */
77: public static final int WT_ATOM_CONSUME = 5;
78:
79: } // WorkerThreadCallback
|