1 25 package org.objectweb.joram.client.jms; 26 27 import java.util.Hashtable ; 28 29 import javax.naming.Reference ; 30 import javax.naming.StringRefAddr ; 31 32 36 public class FactoryParameters implements java.io.Serializable { 37 38 private String host; 39 40 private int port; 41 42 45 private String url; 46 47 52 public int connectingTimer = 0; 53 58 public int txPendingTimer = 0; 59 65 public int cnxPendingTimer = 0; 66 67 72 public boolean asyncSend = false; 73 74 79 public int queueMessageReadMax = 1; 80 81 87 public int topicAckBufferMax = 0; 88 89 96 public boolean multiThreadSync = false; 97 98 104 public int multiThreadSyncDelay = 1; 105 106 110 public int multiThreadSyncThreshold = 10; 111 112 117 public int topicPassivationThreshold = Integer.MAX_VALUE; 118 119 124 public int topicActivationThreshold = 0; 125 126 132 public FactoryParameters(String host, int port) { 133 this.host = host; 134 this.port = port; 135 } 136 137 142 public FactoryParameters(String url) { 143 this.url = url; 144 host = ""; 145 port = -1; 146 } 147 148 151 public FactoryParameters() { 152 } 153 154 157 public String getHost() { 158 return host; 159 } 160 161 162 public int getPort() { 163 return port; 164 } 165 166 169 public String getUrl() { 170 return url; 171 } 172 173 177 public void toReference(Reference ref, String prefix) { 178 180 ref.add(new StringRefAddr (prefix + ".host", getHost())); 181 ref.add(new StringRefAddr (prefix + ".port", 182 new Integer (getPort()).toString())); 183 184 ref.add(new StringRefAddr (prefix + ".url", getUrl())); 185 ref.add(new StringRefAddr (prefix + ".cnxT", 186 new Integer (connectingTimer).toString())); 187 ref.add(new StringRefAddr (prefix + ".txT", 188 new Integer (txPendingTimer).toString())); 189 ref.add(new StringRefAddr (prefix + ".cnxPT", 190 new Integer (cnxPendingTimer).toString())); 191 ref.add(new StringRefAddr (prefix + ".asyncSend", 192 new Boolean (asyncSend).toString())); 193 ref.add(new StringRefAddr (prefix + ".queueMessageReadMax", 194 new Integer (queueMessageReadMax).toString())); 195 ref.add(new StringRefAddr (prefix + ".topicAckBufferMax", 196 new Integer (topicAckBufferMax).toString())); 197 ref.add(new StringRefAddr (prefix + ".multiThreadSync", 198 new Boolean (multiThreadSync).toString())); 199 ref.add(new StringRefAddr (prefix + ".multiThreadSyncDelay", 200 new Integer (multiThreadSyncDelay).toString())); 201 ref.add(new StringRefAddr (prefix + ".multiThreadSyncThreshold", 202 new Integer (multiThreadSyncThreshold).toString())); 203 ref.add(new StringRefAddr (prefix + ".topicPassivationThreshold", 204 new Integer (topicPassivationThreshold).toString())); 205 ref.add(new StringRefAddr (prefix + ".topicActivationThreshold", 206 new Integer (topicActivationThreshold).toString())); 207 } 208 209 213 public void fromReference(Reference ref, String prefix) { 214 216 host = (String ) ref.get(prefix + ".host").getContent(); 217 port = new Integer ((String ) ref.get(prefix + ".port").getContent()).intValue(); 218 219 connectingTimer = new Integer ((String ) ref.get(prefix + ".cnxT").getContent()).intValue(); 220 txPendingTimer = new Integer ((String ) ref.get(prefix + ".txT").getContent()).intValue(); 221 cnxPendingTimer = new Integer ((String ) ref.get(prefix + ".cnxPT").getContent()).intValue(); 222 asyncSend = new Boolean ((String ) ref.get(prefix + ".asyncSend").getContent()).booleanValue(); 223 queueMessageReadMax = new Integer ((String ) ref.get(prefix + ".queueMessageReadMax").getContent()).intValue(); 224 topicAckBufferMax = new Integer ((String ) ref.get(prefix + ".topicAckBufferMax").getContent()).intValue(); 225 multiThreadSync = new Boolean ((String ) ref.get(prefix + ".multiThreadSync").getContent()).booleanValue(); 226 multiThreadSyncDelay = new Integer ((String ) ref.get(prefix + ".multiThreadSyncDelay").getContent()).intValue(); 227 multiThreadSyncThreshold = new Integer ((String ) ref.get(prefix + ".multiThreadSyncThreshold").getContent()).intValue(); 228 topicPassivationThreshold = new Integer ((String ) ref.get(prefix + ".topicPassivationThreshold").getContent()).intValue(); 229 topicActivationThreshold = new Integer ((String ) ref.get(prefix + ".topicActivationThreshold").getContent()).intValue(); 230 } 231 232 public Hashtable toHashtable() { 233 Hashtable h = new Hashtable (); 234 235 h.put("host", getHost()); 236 h.put("port", new Integer (getPort())); 237 h.put("connectingTimer", new Integer (connectingTimer)); 238 h.put("txPendingTimer", new Integer (txPendingTimer)); 239 h.put("cnxPendingTimer", new Integer (cnxPendingTimer)); 240 h.put("asyncSend", new Boolean (asyncSend)); 241 h.put("queueMessageReadMax", new Integer (queueMessageReadMax)); 242 h.put("topicAckBufferMax", new Integer (topicAckBufferMax)); 243 h.put("multiThreadSync", new Boolean (multiThreadSync)); 244 h.put("multiThreadSyncDelay", new Integer (multiThreadSyncDelay)); 245 h.put("multiThreadSyncThreshold", new Integer (multiThreadSyncThreshold)); 246 h.put("topicPassivationThreshold", new Integer (topicPassivationThreshold)); 247 h.put("topicActivationThreshold", new Integer (topicActivationThreshold)); 248 249 return h; 250 } 251 252 public static FactoryParameters fromHashtable(Hashtable h) { 253 FactoryParameters params = new FactoryParameters((String ) h.get("host"), 254 ((Integer ) h.get("port")).intValue()); 255 params.connectingTimer = ((Integer ) h.get("connectingTimer")).intValue(); 256 params.txPendingTimer = ((Integer ) h.get("txPendingTimer")).intValue(); 257 params.cnxPendingTimer = ((Integer ) h.get("cnxPendingTimer")).intValue(); 258 params.asyncSend = ((Boolean ) h.get("asyncSend")).booleanValue(); 259 params.queueMessageReadMax = ((Integer ) h.get("queueMessageReadMax")).intValue(); 260 params.topicAckBufferMax = ((Integer ) h.get("topicAckBufferMax")).intValue(); 261 params.multiThreadSync = ((Boolean ) h.get("multiThreadSync")).booleanValue(); 262 params.multiThreadSyncDelay = ((Integer ) h.get("multiThreadSyncDelay")).intValue(); 263 params.multiThreadSyncThreshold = ((Integer ) h.get("multiThreadSyncThreshold")).intValue(); 264 params.topicPassivationThreshold = ((Integer ) h.get("topicPassivationThreshold")).intValue(); 265 params.topicActivationThreshold = ((Integer ) h.get("topicActivationThreshold")).intValue(); 266 267 return params; 268 } 269 270 public String toString() { 271 return '(' + super.toString() + 272 ",host=" + host + 273 ",port=" + port + 274 ",connectingTimer=" + connectingTimer + 275 ",txPendingTimer=" + txPendingTimer + 276 ",cnxPendingTimer=" + cnxPendingTimer + 277 ",asyncSend=" + asyncSend + 278 ",topicAckBufferMax=" + topicAckBufferMax + 279 ",multiThreadSync=" + multiThreadSync + 280 ",multiThreadSyncDelay=" + multiThreadSyncDelay + 281 ",multiThreadSyncThreshold=" + multiThreadSyncThreshold + 282 ",topicPassivationThreshold=" + topicPassivationThreshold + 283 ",topicActivationThreshold=" + topicActivationThreshold + ')'; 284 } 285 } 286 | Popular Tags |