KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ersatz > resourceadapter > ConnectionRequestInfoImpl


1 /*
2  * Created on December 11, 2003
3  *
4  * ConnectionRequestInfoImpl.java is used to test the J2EE Connector 1.5
5  * as implemented by JOnAS.
6  */

7 package ersatz.resourceadapter;
8
9 import javax.naming.Reference;
10 import javax.resource.spi.ConnectionRequestInfo;
11
12 /**
13  * @author Bob Kruse
14  *
15  * used to test the J2EE Connector as implemented by JOnAS.
16  *
17  */

18 public class ConnectionRequestInfoImpl implements ConnectionRequestInfo
19 {
20     Reference reference;
21     // Resource adapter name form EIS_URL <config-property>
22
public String raName="";
23     // Managed Connection Factory <config-property>s
24
String serverName="";
25     String portNumber="";
26     String userName="";
27     String password="";
28     String protocol="";
29     
30     String Id=""; // used in hashcode() for ConnectionRequestInfo
31
String cName = "ConnectionRequestInfoImpl";
32     //
33
// constructor
34
public ConnectionRequestInfoImpl()
35     {
36         Id="";
37         Utility.log(cName+"() "+this );
38     }
39     public ConnectionRequestInfoImpl(ConnectionRequestInfoImpl crii)
40     {
41         raName=crii.raName;
42         serverName=crii.serverName;
43         portNumber=crii.portNumber;
44         userName =crii.userName ;
45         password =crii.password ;
46         protocol =crii.protocol ;
47         Id ="";
48         Utility.log(cName+"(crii) "+this);
49         
50     }
51
52     // module to add additional connection properties than
53
// the ones configured for the ConnectionFactory. This
54
// class is passed to the App Server and will be used
55
// on matchManagedConnections or createConnection
56
// methods by the App Server.
57
//
58
//
59
public void setUserName(String u) {
60         userName=u;
61         Utility.log(cName+".setUserName="+u);
62     }
63     public void setPassword(String p) {
64         password=p;
65         Utility.log(cName+".setPassword="+p);
66     }
67     public String getUserName() {
68         Utility.log(cName+".getUserName="+userName);
69         return userName;
70     }
71     public String getPassword() {
72         Utility.log(cName+".getPassword="+password);
73         return password;
74     }
75     public void setRaName(String s) {
76         raName=s;
77     }
78     public void setServerName(String s) {
79         serverName=s;
80     }
81     public void setPortNumber(String s) {
82         portNumber=s;
83     }
84     public void setProtocol(String s) {
85         protocol=s;
86     }
87     public String getRaName() {
88         return raName;
89     }
90     public String getServerName() {
91         return serverName;
92     }
93     public String getPortNumber() {
94         return portNumber;
95     }
96     public String getProtocol() {
97         return protocol;
98     }
99     private void setId()
100     {
101         if (Id == null || Id.length() == 0)
102             Id=raName + serverName + portNumber + userName + password + protocol;
103         
104     }
105     public String getId()
106     {
107         setId();
108         return Id;
109         
110     }
111     //
112
// hashCode and equals method used in ConnectionRequestInfo,
113
// ManagedConnectionFactory
114
public int hashCode()
115     {
116         setId();
117         int hash = Id.hashCode();
118         return hash;
119     }
120     public boolean equals(Object obj)
121     {
122         boolean ret = false;
123         if (obj!=null) {
124             if ( obj instanceof ConnectionRequestInfoImpl) {
125                 ConnectionRequestInfoImpl other = (ConnectionRequestInfoImpl)obj;
126                 try {
127                    ret= raName.equalsIgnoreCase(other.raName) &&
128                         serverName.equalsIgnoreCase(other.serverName) &&
129                         portNumber.equalsIgnoreCase(other.portNumber) &&
130                         userName.equalsIgnoreCase(other.userName) &&
131                         password.equalsIgnoreCase(other.password) &&
132                         protocol.equalsIgnoreCase(other.protocol);
133                 } catch (Exception e) {
134                     ret=false;
135                 }
136             }
137         }
138         Utility.log(cName+".equals "+ret);
139         return ret;
140     }
141
142 }
Popular Tags