KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ersatz > resourceadapter > ActivationSpecImpl


1 /*
2  * Created on January 12, 2004
3  *
4  * ActivationSpecImpl.java is used to test JCA 1.5
5  * as implemented by JOnAS. This class implements the ActivationSpec Interface
6  *
7  * An ActivationSpec JavaBean represents inbound connectivity information from
8  * an EIS instance
9  */

10 package ersatz.resourceadapter;
11
12 import javax.resource.ResourceException;
13 import javax.resource.spi.ResourceAdapter;
14 import javax.resource.spi.ActivationSpec;
15
16     // ActivationSpec interface extends ResourceAdapterAssociation interface.
17

18 public class ActivationSpecImpl implements ActivationSpec,
19                                            java.io.Serializable
20 {
21     private transient ResourceAdapter ra = null; // loaded by Application Server
22
private boolean raLoaded;
23     private String messageObjectType;
24     String cName = "ActivationSpecImpl";
25     ResourceAdapterImpl rai;
26     
27     public ActivationSpecImpl()
28     {
29         Utility.log(cName+".constructor");
30     }
31     public void validate()
32         throws javax.resource.spi.InvalidPropertyException
33     {
34         Utility.log(cName+".validate. eis="+rai.EIS_URL);
35     }
36     public ResourceAdapter getResourceAdapter()
37     {
38         return ra;
39     }
40     /** Set the ResourceAdapter association.
41      *
42      * @param ra ResourceAdapter passed in by Application Server (JOnAS)
43      * @exception javax.resource.ResourceException
44     **/

45     public void setResourceAdapter(ResourceAdapter ra) throws ResourceException
46     {
47         Utility.log(cName+".setResourceAdapter arg="+ra);
48         rai = (ResourceAdapterImpl)ra;
49         if (ra==null) {
50             String s = "Application Server cannot set ResourceAdapter to null";
51             Utility.log(cName+".setResourceAdapter error: "+s);
52             throw new ResourceException(s);
53         }
54         if (this.ra==null) {
55             this.ra = ra;
56         } else if (this.ra != ra) {
57             String s = "ResourceAdapter already set to "+this.ra
58                        +". Must not change association";
59             Utility.log(cName+".setResourceAdapter error: "+s);
60             throw new ResourceException(s);
61         }
62     }
63     
64     // test "setter" methods in Message Driven Bean MessageTakerMD.java
65
// as specified in deployment descriptor
66
//
67
public void setFormat(String f) {
68         messageObjectType=f; // f="String"
69
}
70     public String getFormat() {
71         return messageObjectType;
72     }
73      // TODO ...other methods
74
}
Popular Tags