01: /*
02: * Created on January 27, 2004
03: *
04: * WorkAdapter.java is used to test JCA 1.5 as implemented by
05: * JOnAS. This class implements the WorkListener Interface
06: *
07: */
08: package ersatz.resourceadapter;
09:
10: import javax.resource.spi.work.WorkEvent;
11: import javax.resource.spi.work.WorkAdapter;
12: import javax.resource.spi.work.WorkException;
13:
14: /**
15: * @author Bob Kruse
16: *
17: * JCA1.5 WorkAdapter interface
18: *
19: * used to test the J2EE Connector as implemented by JOnAS.
20: *
21: * This is the "WorkListener"
22: *
23: */
24: public class WorkAdapterImpl extends WorkAdapter {
25: String cName = "WorkAdapterImpl";
26: WorkImpl wi;
27: WorkException wex;
28:
29: /*
30: e.getType() returns these values
31:
32: int WORK_ACCEPTED = 1;
33: int WORK_REJECTED = 2;
34: int WORK_STARTED = 3;
35: int WORK_COMPLETED = 4;
36: */
37:
38: public void workStarted(WorkEvent e) {
39: wex = e.getException();
40: if (wex == null) {
41: // no exception occurred
42: wi = (WorkImpl) e.getWork();
43: Utility.log(cName
44: + ".workStarted for WorkEvent Work content="
45: + wi.getWorkType() + ", " + e.getType());
46: } else {
47: Utility.log(cName + ".workStarted WorkException=" + wex);
48: }
49: }
50:
51: public void workAccepted(WorkEvent e) {
52: wex = e.getException();
53: if (wex == null) {
54: // no exception occurred
55: wi = (WorkImpl) e.getWork();
56: Utility.log(cName
57: + ".workAccepted for WorkEvent Work content="
58: + wi.getWorkType() + ", " + e.getType());
59: } else {
60: Utility.log(cName + ".workAccepted WorkException=" + wex);
61: }
62: }
63:
64: public void workRejected(WorkEvent e) {
65: wex = e.getException();
66: if (wex == null) {
67: // no exception occurred
68: wi = (WorkImpl) e.getWork();
69: Utility.log(cName
70: + ".workRejected for WorkEvent Work content="
71: + wi.getWorkType() + ", " + e.getType());
72: } else {
73: Utility.log(cName + ".workRejected WorkException=" + wex);
74: }
75: }
76:
77: public void workCompleted(WorkEvent e) {
78: wex = e.getException();
79: if (wex == null) {
80: // no exception occurred
81: wi = (WorkImpl) e.getWork();
82: Utility.log(cName
83: + ".workCompleted for WorkEvent Work content="
84: + wi.getWorkType() + ", " + e.getType());
85: } else {
86: Utility.log(cName + ".workCompleted WorkException=" + wex);
87: }
88: }
89: }
|