001: /*
002: * Created on December 11, 2003
003: *
004: * ConnectionRequestInfoImpl.java is used to test the J2EE Connector 1.5
005: * as implemented by JOnAS.
006: */
007: package ersatz.resourceadapter;
008:
009: import javax.naming.Reference;
010: import javax.resource.spi.ConnectionRequestInfo;
011:
012: /**
013: * @author Bob Kruse
014: *
015: * used to test the J2EE Connector as implemented by JOnAS.
016: *
017: */
018: public class ConnectionRequestInfoImpl implements ConnectionRequestInfo {
019: Reference reference;
020: // Resource adapter name form EIS_URL <config-property>
021: public String raName = "";
022: // Managed Connection Factory <config-property>s
023: String serverName = "";
024: String portNumber = "";
025: String userName = "";
026: String password = "";
027: String protocol = "";
028:
029: String Id = ""; // used in hashcode() for ConnectionRequestInfo
030: String cName = "ConnectionRequestInfoImpl";
031:
032: //
033: // constructor
034: public ConnectionRequestInfoImpl() {
035: Id = "";
036: Utility.log(cName + "() " + this );
037: }
038:
039: public ConnectionRequestInfoImpl(ConnectionRequestInfoImpl crii) {
040: raName = crii.raName;
041: serverName = crii.serverName;
042: portNumber = crii.portNumber;
043: userName = crii.userName;
044: password = crii.password;
045: protocol = crii.protocol;
046: Id = "";
047: Utility.log(cName + "(crii) " + this );
048:
049: }
050:
051: // module to add additional connection properties than
052: // the ones configured for the ConnectionFactory. This
053: // class is passed to the App Server and will be used
054: // on matchManagedConnections or createConnection
055: // methods by the App Server.
056: //
057: //
058: public void setUserName(String u) {
059: userName = u;
060: Utility.log(cName + ".setUserName=" + u);
061: }
062:
063: public void setPassword(String p) {
064: password = p;
065: Utility.log(cName + ".setPassword=" + p);
066: }
067:
068: public String getUserName() {
069: Utility.log(cName + ".getUserName=" + userName);
070: return userName;
071: }
072:
073: public String getPassword() {
074: Utility.log(cName + ".getPassword=" + password);
075: return password;
076: }
077:
078: public void setRaName(String s) {
079: raName = s;
080: }
081:
082: public void setServerName(String s) {
083: serverName = s;
084: }
085:
086: public void setPortNumber(String s) {
087: portNumber = s;
088: }
089:
090: public void setProtocol(String s) {
091: protocol = s;
092: }
093:
094: public String getRaName() {
095: return raName;
096: }
097:
098: public String getServerName() {
099: return serverName;
100: }
101:
102: public String getPortNumber() {
103: return portNumber;
104: }
105:
106: public String getProtocol() {
107: return protocol;
108: }
109:
110: private void setId() {
111: if (Id == null || Id.length() == 0)
112: Id = raName + serverName + portNumber + userName + password
113: + protocol;
114:
115: }
116:
117: public String getId() {
118: setId();
119: return Id;
120:
121: }
122:
123: //
124: // hashCode and equals method used in ConnectionRequestInfo,
125: // ManagedConnectionFactory
126: public int hashCode() {
127: setId();
128: int hash = Id.hashCode();
129: return hash;
130: }
131:
132: public boolean equals(Object obj) {
133: boolean ret = false;
134: if (obj != null) {
135: if (obj instanceof ConnectionRequestInfoImpl) {
136: ConnectionRequestInfoImpl other = (ConnectionRequestInfoImpl) obj;
137: try {
138: ret = raName.equalsIgnoreCase(other.raName)
139: && serverName
140: .equalsIgnoreCase(other.serverName)
141: && portNumber
142: .equalsIgnoreCase(other.portNumber)
143: && userName
144: .equalsIgnoreCase(other.userName)
145: && password
146: .equalsIgnoreCase(other.password)
147: && protocol
148: .equalsIgnoreCase(other.protocol);
149: } catch (Exception e) {
150: ret = false;
151: }
152: }
153: }
154: Utility.log(cName + ".equals " + ret);
155: return ret;
156: }
157:
158: }
|