1 22 package org.jboss.mq.il.http; 23 24 import java.io.Serializable ; 25 26 import org.jboss.logging.Logger; 27 import org.jboss.mq.ReceiveRequest; 28 import org.jboss.mq.SpyDestination; 29 import org.jboss.mq.il.ClientIL; 30 31 38 public class HTTPClientIL implements ClientIL, Serializable 39 { 40 static final long serialVersionUID = 3215139925343217398L; 41 public boolean stopped = true; 42 43 private static Logger log = Logger.getLogger(HTTPClientIL.class); 44 private String clientIlId = null; 45 46 public HTTPClientIL(String clientIlId) 47 { 48 this.clientIlId = clientIlId; 49 if (log.isTraceEnabled()) 50 { 51 log.trace("created(" + clientIlId + ")"); 52 } 53 } 54 55 public void close() throws Exception 56 { 57 if (log.isTraceEnabled()) 58 { 59 log.trace("close()"); 60 } 61 this.throwIllegalStateExceptionIfStopped(); 62 HTTPILRequest request = new HTTPILRequest(); 63 request.setMethodName("asynchClose"); 64 HTTPClientILStorageQueue.getInstance().put(request, this.clientIlId); 65 } 66 67 public void deleteTemporaryDestination(SpyDestination dest) throws Exception 68 { 69 if (log.isTraceEnabled()) 70 { 71 log.trace("deleteTemporaryDestination(SpyDestination " + dest.toString() + ")"); 72 } 73 this.throwIllegalStateExceptionIfStopped(); 74 HTTPILRequest request = new HTTPILRequest(); 75 request.setMethodName("asynchDeleteTemporaryDestination"); 76 request.setArguments(new Object [] 77 {dest}, new Class [] 78 {SpyDestination.class}); 79 HTTPClientILStorageQueue.getInstance().put(request, this.clientIlId); 80 } 81 82 public void pong(long serverTime) throws Exception 83 { 84 this.throwIllegalStateExceptionIfStopped(); 85 HTTPILRequest request = new HTTPILRequest(); 86 request.setMethodName("asynchPong"); 87 request.setArguments(new Object [] 88 {new Long (serverTime)}, new Class [] 89 {long.class}); 90 HTTPClientILStorageQueue.getInstance().put(request, this.clientIlId); 91 } 92 93 public void receive(ReceiveRequest[] messages) throws Exception 94 { 95 if (log.isTraceEnabled()) 96 { 97 log.trace("receive(ReceiveRequest[] arraylength=" + String.valueOf(messages.length) + ")"); 98 } 99 this.throwIllegalStateExceptionIfStopped(); 100 HTTPILRequest request = new HTTPILRequest(); 101 request.setMethodName("asynchDeliver"); 102 request.setArguments(new Object [] 103 {messages}, new Class [] 104 {ReceiveRequest[].class}); 105 HTTPClientILStorageQueue.getInstance().put(request, this.clientIlId); 106 } 107 108 private void throwIllegalStateExceptionIfStopped() throws IllegalStateException 109 { 110 if (this.stopped) 111 { 112 throw new IllegalStateException ("The client IL is stopped."); 113 } 114 } 115 116 } | Popular Tags |