1 22 package org.jboss.mq.il.http; 23 24 import java.io.Serializable ; 25 import java.net.URL ; 26 27 import javax.jms.Destination ; 28 import javax.jms.Queue ; 29 import javax.jms.TemporaryQueue ; 30 import javax.jms.TemporaryTopic ; 31 import javax.jms.Topic ; 32 import javax.transaction.xa.Xid ; 33 34 import org.jboss.logging.Logger; 35 import org.jboss.mq.AcknowledgementRequest; 36 import org.jboss.mq.ConnectionToken; 37 import org.jboss.mq.DurableSubscriptionID; 38 import org.jboss.mq.Recoverable; 39 import org.jboss.mq.SpyDestination; 40 import org.jboss.mq.SpyMessage; 41 import org.jboss.mq.Subscription; 42 import org.jboss.mq.TransactionRequest; 43 import org.jboss.mq.il.ServerIL; 44 45 57 public class HTTPServerIL implements Serializable , ServerIL, Recoverable 58 { 59 static final long serialVersionUID = -864073076154976490L; 60 61 private static Logger log = Logger.getLogger(HTTPClient.class); 62 63 private String serverUrlValue = null; 64 private URL serverUrl = null; 65 66 public HTTPServerIL(String url) throws Exception 67 { 68 if (log.isTraceEnabled()) 69 { 70 log.trace("created(String " + url + ")"); 71 } 72 this.serverUrlValue = url; 73 } 74 75 public void acknowledge(ConnectionToken dc, AcknowledgementRequest item) throws Exception 76 { 77 if (log.isTraceEnabled()) 78 { 79 log.trace("acknowledge(ConnectionToken " + dc.toString() + ", AcknowledgementRequest " + item.toString() + ")"); 80 } 81 HTTPILRequest request = new HTTPILRequest(); 82 request.setMethodName("acknowledge"); 83 request.setArguments(new Object [] 84 {dc, item}, new Class [] 85 {ConnectionToken.class, AcknowledgementRequest.class}); 86 this.postRequest(request); 87 } 88 89 public void addMessage(ConnectionToken dc, SpyMessage message) throws Exception 90 { 91 if (log.isTraceEnabled()) 92 { 93 log.trace("addMessage(ConnectionToken " + dc.toString() + ", SpyMessage " + message.toString() + ")"); 94 } 95 HTTPILRequest request = new HTTPILRequest(); 96 request.setMethodName("addMessage"); 97 request.setArguments(new Object [] 98 {dc, message}, new Class [] 99 {ConnectionToken.class, SpyMessage.class}); 100 this.postRequest(request); 101 } 102 103 public String authenticate(String userName, String password) throws Exception 104 { 105 if (log.isTraceEnabled()) 106 { 107 log.trace("authenticate(String " + userName + ", String " + password + ")"); 108 } 109 HTTPILRequest request = new HTTPILRequest(); 110 request.setMethodName("authenticate"); 111 request.setArguments(new Object [] 112 {userName, password}, new Class [] 113 {String .class, String .class}); 114 return (String )this.postRequest(request); 115 } 116 117 public SpyMessage[] browse(ConnectionToken dc, Destination dest, String selector) throws Exception 118 { 119 if (log.isTraceEnabled()) 120 { 121 log.trace("browse(ConnectionToken " + dc.toString() + ", Destination " + dest.toString() + ", String " + selector + ")"); 122 } 123 HTTPILRequest request = new HTTPILRequest(); 124 request.setMethodName("browse"); 125 request.setArguments(new Object [] 126 {dc, dest, selector}, new Class [] 127 {ConnectionToken.class, Destination .class, String .class}); 128 return (SpyMessage[])this.postRequest(request); 129 } 130 131 public void checkID(String ID) throws Exception 132 { 133 if (log.isTraceEnabled()) 134 { 135 log.trace("checkID(String " + ID + ")"); 136 } 137 HTTPILRequest request = new HTTPILRequest(); 138 request.setMethodName("checkID"); 139 request.setArguments(new Object [] 140 {ID}, new Class [] 141 {String .class}); 142 this.postRequest(request); 143 } 144 145 public String checkUser(String userName, String password) throws Exception 146 { 147 if (log.isTraceEnabled()) 148 { 149 log.trace("checkUser(String " + userName + ", String " + password + ")"); 150 } 151 HTTPILRequest request = new HTTPILRequest(); 152 request.setMethodName("checkUser"); 153 request.setArguments(new Object [] 154 {userName, password}, new Class [] 155 {String .class, String .class}); 156 return (String )this.postRequest(request); 157 } 158 159 public ServerIL cloneServerIL() throws Exception 160 { 161 if (log.isTraceEnabled()) 162 { 163 log.trace("cloneServerIL()"); 164 } 165 return this; } 167 168 public void connectionClosing(ConnectionToken dc) throws Exception 169 { 170 if (log.isTraceEnabled()) 171 { 172 log.trace("connectionClosing(ConnectionToken " + dc.toString() + ")"); 173 } 174 HTTPILRequest request = new HTTPILRequest(); 175 request.setMethodName("connectionClosing"); 176 request.setArguments(new Object [] 177 {dc}, new Class [] 178 {ConnectionToken.class}); 179 this.postRequest(request); 180 } 181 182 public Queue createQueue(ConnectionToken dc, String dest) throws Exception 183 { 184 if (log.isTraceEnabled()) 185 { 186 log.trace("createQueue(ConnectionToken " + dc.toString() + ", String " + dest.toString() + ")"); 187 } 188 HTTPILRequest request = new HTTPILRequest(); 189 request.setMethodName("createQueue"); 190 request.setArguments(new Object [] 191 {dc, dest}, new Class [] 192 {ConnectionToken.class, String .class}); 193 return (Queue )this.postRequest(request); 194 } 195 196 public Topic createTopic(ConnectionToken dc, String dest) throws Exception 197 { 198 if (log.isTraceEnabled()) 199 { 200 log.trace("createTopic(ConnectionToken " + dc.toString() + ", String " + dest.toString() + ")"); 201 } 202 HTTPILRequest request = new HTTPILRequest(); 203 request.setMethodName("createTopic"); 204 request.setArguments(new Object [] 205 {dc, dest}, new Class [] 206 {ConnectionToken.class, String .class}); 207 return (Topic )this.postRequest(request); 208 } 209 210 public void deleteTemporaryDestination(ConnectionToken dc, SpyDestination dest) throws Exception 211 { 212 if (log.isTraceEnabled()) 213 { 214 log.trace("deleteTemporaryDestination(ConnectionToken " + dc.toString() + ", SpyDestination " + dest.toString() + ")"); 215 } 216 HTTPILRequest request = new HTTPILRequest(); 217 request.setMethodName("deleteTemporaryDestination"); 218 request.setArguments(new Object [] 219 {dc, dest}, new Class [] 220 {ConnectionToken.class, SpyDestination.class}); 221 this.postRequest(request); 222 } 223 224 public void destroySubscription(ConnectionToken dc, DurableSubscriptionID id) throws Exception 225 { 226 if (log.isTraceEnabled()) 227 { 228 log.trace("destroySubscription(ConnectionToken " + dc.toString() + ", DurableSubscriptionID " + id.toString() + ")"); 229 } 230 HTTPILRequest request = new HTTPILRequest(); 231 request.setMethodName("destroySubscription"); 232 request.setArguments(new Object [] 233 {dc, id}, new Class [] 234 {ConnectionToken.class, DurableSubscriptionID.class}); 235 this.postRequest(request); 236 } 237 238 public String getID() throws Exception 239 { 240 if (log.isTraceEnabled()) 241 { 242 log.trace("getID()"); 243 } 244 HTTPILRequest request = new HTTPILRequest(); 245 request.setMethodName("getID"); 246 return (String )this.postRequest(request); 247 } 248 249 public TemporaryQueue getTemporaryQueue(ConnectionToken dc) throws Exception 250 { 251 if (log.isTraceEnabled()) 252 { 253 log.trace("getTemporaryQueue(ConnectionToken " + dc.toString() + ")"); 254 } 255 HTTPILRequest request = new HTTPILRequest(); 256 request.setMethodName("getTemporaryQueue"); 257 request.setArguments(new Object [] 258 {dc}, new Class [] 259 {ConnectionToken.class}); 260 return (TemporaryQueue )this.postRequest(request); 261 } 262 263 public TemporaryTopic getTemporaryTopic(ConnectionToken dc) throws Exception 264 { 265 if (log.isTraceEnabled()) 266 { 267 log.trace("getTemporaryTopic(ConnectionToken " + dc.toString() + ")"); 268 } 269 HTTPILRequest request = new HTTPILRequest(); 270 request.setMethodName("getTemporaryTopic"); 271 request.setArguments(new Object [] 272 {dc}, new Class [] 273 {ConnectionToken.class}); 274 return (TemporaryTopic )this.postRequest(request); 275 } 276 277 public void ping(ConnectionToken dc, long clientTime) throws Exception 278 { 279 if (log.isTraceEnabled()) 281 { 282 log.trace("ping(ConnectionToken " + dc.toString() + ", long " + String.valueOf(clientTime) + ")"); 283 } 284 HTTPILRequest request = new HTTPILRequest(); 285 request.setMethodName("ping"); 286 request.setArguments(new Object [] 287 {dc, new Long (clientTime)}, new Class [] 288 {ConnectionToken.class, Long .class}); 289 this.postRequest(request); 290 } 291 292 public SpyMessage receive(ConnectionToken dc, int subscriberId, long wait) throws Exception 293 { 294 if (log.isTraceEnabled()) 295 { 296 log.trace("receive(ConnectionToken " + dc.toString() + ", int " + String.valueOf(subscriberId) + ", long " + String.valueOf(wait) + ")"); 297 } 298 HTTPILRequest request = new HTTPILRequest(); 299 request.setMethodName("receive"); 300 request.setArguments(new Object [] 301 {dc, new Integer (subscriberId), new Long (wait)}, new Class [] 302 {ConnectionToken.class, Integer .class, Long .class}); 303 return (SpyMessage)this.postRequest(request); 304 } 305 306 public void setConnectionToken(ConnectionToken newConnectionToken) throws Exception 307 { 308 } 310 311 public void setEnabled(ConnectionToken dc, boolean enabled) throws Exception 312 { 313 if (log.isTraceEnabled()) 314 { 315 log.trace("setEnabled(ConnectionToken " + dc.toString() + ", boolean " + String.valueOf(enabled) + ")"); 316 } 317 HTTPILRequest request = new HTTPILRequest(); 318 request.setMethodName("setEnabled"); 319 request.setArguments(new Object [] 320 {dc, new Boolean (enabled)}, new Class [] 321 {ConnectionToken.class, Boolean .class}); 322 this.postRequest(request); 323 } 324 325 public void subscribe(ConnectionToken dc, Subscription s) throws Exception 326 { 327 if (log.isTraceEnabled()) 328 { 329 log.trace("subscribe(ConnectionToken " + dc.toString() + ", Subscription " + s.toString() + ")"); 330 } 331 HTTPILRequest request = new HTTPILRequest(); 332 request.setMethodName("subscribe"); 333 request.setArguments(new Object [] 334 {dc, s}, new Class [] 335 {ConnectionToken.class, Subscription.class}); 336 this.postRequest(request); 337 } 338 339 public void transact(ConnectionToken dc, TransactionRequest t) throws Exception 340 { 341 if (log.isTraceEnabled()) 342 { 343 log.trace("transact(ConnectionToken " + dc.toString() + ", TransactionRequest " + t.toString() + ")"); 344 } 345 HTTPILRequest request = new HTTPILRequest(); 346 request.setMethodName("transact"); 347 request.setArguments(new Object [] 348 {dc, t}, new Class [] 349 {ConnectionToken.class, TransactionRequest.class}); 350 this.postRequest(request); 351 } 352 353 public Xid [] recover(ConnectionToken dc, int flags) throws Exception 354 { 355 if (log.isTraceEnabled()) 356 log.trace("recover(ConnectionToken " + dc + ", flags=" + flags + ")"); 357 HTTPILRequest request = new HTTPILRequest(); 358 request.setMethodName("recover"); 359 request.setArguments 360 ( 361 new Object [] { dc, new Integer (flags) }, 362 new Class [] { ConnectionToken.class, Integer .class } 363 ); 364 return (Xid []) this.postRequest(request); 365 } 366 367 public void unsubscribe(ConnectionToken dc, int subscriptionId) throws Exception 368 { 369 if (log.isTraceEnabled()) 370 { 371 log.trace("unsubscribe(ConnectionToken " + dc.toString() + ", int " + String.valueOf(subscriptionId) + ")"); 372 } 373 HTTPILRequest request = new HTTPILRequest(); 374 request.setMethodName("unsubscribe"); 375 request.setArguments(new Object [] 376 {dc, new Integer (subscriptionId)}, new Class [] 377 {ConnectionToken.class, Integer .class}); 378 this.postRequest(request); 379 } 380 381 private Object postRequest(HTTPILRequest request) throws Exception 382 { 383 if (log.isTraceEnabled()) 384 { 385 log.trace("postRequest(HTTPILRequest " + request.toString() + ")"); 386 } 387 if (this.serverUrl == null) 388 { 389 this.serverUrl = HTTPClient.resolveServerUrl(this.serverUrlValue); 390 } 391 return HTTPClient.post(this.serverUrl, request); 392 } 393 } | Popular Tags |