KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ersatz > resourceadapter > WorkAdapterImpl


1 /*
2  * Created on January 27, 2004
3  *
4  * WorkAdapter.java is used to test JCA 1.5 as implemented by
5  * JOnAS. This class implements the WorkListener Interface
6  *
7  */

8 package ersatz.resourceadapter;
9
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 {
26     String cName = "WorkAdapterImpl";
27     WorkImpl wi;
28     WorkException wex;
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     {
40         wex=e.getException();
41         if (wex==null) {
42             // no exception occurred
43
wi=(WorkImpl)e.getWork();
44             Utility.log(cName+".workStarted for WorkEvent Work content="
45                              +wi.getWorkType()+", "+e.getType());
46         } else {
47             Utility.log(cName+".workStarted WorkException="+wex);
48         }
49     }
50     public void workAccepted(WorkEvent e)
51     {
52         wex=e.getException();
53         if (wex==null) {
54             // no exception occurred
55
wi=(WorkImpl)e.getWork();
56             Utility.log(cName+".workAccepted for WorkEvent Work content="
57                              +wi.getWorkType()+", "+e.getType());
58         } else {
59             Utility.log(cName+".workAccepted WorkException="+wex);
60         }
61     }
62     public void workRejected(WorkEvent e)
63     {
64         wex=e.getException();
65         if (wex==null) {
66             // no exception occurred
67
wi=(WorkImpl)e.getWork();
68             Utility.log(cName+".workRejected for WorkEvent Work content="
69                              +wi.getWorkType()+", "+e.getType());
70         } else {
71             Utility.log(cName+".workRejected WorkException="+wex);
72         }
73     }
74     public void workCompleted(WorkEvent e)
75     {
76         wex=e.getException();
77         if (wex==null) {
78             // no exception occurred
79
wi=(WorkImpl)e.getWork();
80             Utility.log(cName+".workCompleted for WorkEvent Work content="
81                              +wi.getWorkType()+", "+e.getType());
82         } else {
83             Utility.log(cName+".workCompleted WorkException="+wex);
84         }
85     }
86 }
Popular Tags