1 22 package org.jboss.resource.adapter.jms; 23 24 import javax.resource.spi.ConnectionRequestInfo ; 25 26 import javax.jms.Session ; 27 28 import org.jboss.util.Strings; 29 30 37 public class JmsConnectionRequestInfo 38 implements ConnectionRequestInfo 39 { 40 private String userName; 41 private String password; 42 private String clientID; 43 44 private boolean transacted = true; 45 private int acknowledgeMode = Session.AUTO_ACKNOWLEDGE; 46 private int type = JmsConnectionFactory.BOTH; 47 48 51 public JmsConnectionRequestInfo(JmsMCFProperties prop) 52 { 53 this.userName = prop.getUserName(); 54 this.password = prop.getPassword(); 55 this.clientID = prop.getClientID(); 56 this.type = prop.getType(); 57 } 58 59 62 public JmsConnectionRequestInfo(final boolean transacted, 63 final int acknowledgeMode, 64 final int type) 65 { 66 this.transacted = transacted; 67 this.acknowledgeMode = acknowledgeMode; 68 this.type = type; 69 } 70 71 74 public void setDefaults(JmsMCFProperties prop) 75 { 76 if (userName == null) 77 userName = prop.getUserName(); if (password == null) 79 password = prop.getPassword(); if (clientID == null) 81 clientID = prop.getClientID(); } 83 84 public String getUserName() 85 { 86 return userName; 87 } 88 89 public void setUserName(String name) 90 { 91 userName = name; 92 } 93 94 public String getPassword() 95 { 96 return password; 97 } 98 99 public void setPassword(String password) 100 { 101 this.password = password; 102 } 103 104 public String getClientID() 105 { 106 return clientID; 107 } 108 109 public void setClientID(String clientID) 110 { 111 this.clientID = clientID; 112 } 113 114 public boolean isTransacted() 115 { 116 return transacted; 117 } 118 119 public int getAcknowledgeMode() 120 { 121 return acknowledgeMode; 122 } 123 124 public int getType() 125 { 126 return type; 127 } 128 129 public boolean equals(Object obj) 130 { 131 if (obj == null) return false; 132 if (obj instanceof JmsConnectionRequestInfo) 133 { 134 JmsConnectionRequestInfo you = (JmsConnectionRequestInfo) obj; 135 return (this.transacted == you.isTransacted() && 136 this.acknowledgeMode == you.getAcknowledgeMode() && 137 this.type == you.getType() && 138 Strings.compare(userName, you.getUserName()) && 139 Strings.compare(password, you.getPassword()) && 140 Strings.compare(clientID, you.getClientID())); 141 } 142 else 143 return false; 144 } 145 146 public int hashCode() 147 { 148 int hashCode = 0; 149 if (transacted) 150 hashCode += 1; 151 if (type == JmsConnectionFactory.QUEUE) 152 hashCode += 3; 153 else if (type == JmsConnectionFactory.TOPIC) 154 hashCode += 5; 155 if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE) 156 hashCode += 7; 157 else if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE) 158 hashCode += 11; 159 if (userName != null) 160 hashCode += userName.hashCode(); 161 if (password != null) 162 hashCode += password.hashCode(); 163 if (clientID != null) 164 hashCode += clientID.hashCode(); 165 166 return hashCode; 167 } 168 } 169 | Popular Tags |