1 18 package org.apache.activemq.transport; 19 20 import java.io.IOException ; 21 22 import org.apache.activemq.util.ServiceSupport; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 31 public abstract class TransportSupport extends ServiceSupport implements Transport { 32 private static final Log log = LogFactory.getLog(TransportSupport.class); 33 34 TransportListener transportListener; 35 36 39 public TransportListener getTransportListener() { 40 return transportListener; 41 } 42 43 48 public void setTransportListener(TransportListener commandListener) { 49 this.transportListener = commandListener; 50 } 51 52 58 public Object narrow(Class target) { 59 boolean assignableFrom = target.isAssignableFrom(getClass()); 60 if (assignableFrom) { 61 return this; 62 } 63 return null; 64 } 65 66 public FutureResponse asyncRequest(Object command, ResponseCallback responseCallback) throws IOException { 67 throw new AssertionError ("Unsupported Method"); 68 } 69 70 public Object request(Object command) throws IOException { 71 throw new AssertionError ("Unsupported Method"); 72 } 73 74 public Object request(Object command,int timeout) throws IOException { 75 throw new AssertionError ("Unsupported Method"); 76 } 77 78 81 public void doConsume(Object command) { 82 if (command != null) { 83 if (transportListener != null) { 84 transportListener.onCommand(command); 85 } 86 else { 87 log.error("No transportListener available to process inbound command: " + command); 88 } 89 } 90 } 91 92 95 public void onException(IOException e) { 96 if (transportListener != null) { 97 transportListener.onException(e); 98 } 99 } 100 101 protected void checkStarted() throws IOException { 102 if (!isStarted()) { 103 throw new IOException ("The transport is not running."); 104 } 105 } 106 107 } 108 | Popular Tags |