1 18 package org.apache.activemq.transport; 19 20 import java.io.IOException ; 21 24 public class TransportFilter implements TransportListener,Transport{ 25 final protected Transport next; 26 protected TransportListener transportListener; 27 28 public TransportFilter(Transport next){ 29 this.next=next; 30 } 31 32 public TransportListener getTransportListener(){ 33 return transportListener; 34 } 35 36 public void setTransportListener(TransportListener channelListener){ 37 this.transportListener=channelListener; 38 if(channelListener==null) 39 next.setTransportListener(null); 40 else 41 next.setTransportListener(this); 42 } 43 44 49 public void start() throws Exception { 50 if(next==null) 51 throw new IOException ("The next channel has not been set."); 52 if(transportListener==null) 53 throw new IOException ("The command listener has not been set."); 54 next.start(); 55 } 56 57 60 public void stop() throws Exception { 61 next.stop(); 62 } 63 64 public void onCommand(Object command){ 65 transportListener.onCommand(command); 66 } 67 68 71 public Transport getNext(){ 72 return next; 73 } 74 75 public String toString(){ 76 return next.toString(); 77 } 78 79 public void oneway(Object command) throws IOException { 80 next.oneway(command); 81 } 82 83 public FutureResponse asyncRequest(Object command,ResponseCallback responseCallback) throws IOException { 84 return next.asyncRequest(command,null); 85 } 86 87 public Object request(Object command) throws IOException { 88 return next.request(command); 89 } 90 91 public Object request(Object command,int timeout) throws IOException { 92 return next.request(command,timeout); 93 } 94 95 public void onException(IOException error){ 96 transportListener.onException(error); 97 } 98 99 public void transportInterupted(){ 100 transportListener.transportInterupted(); 101 } 102 103 public void transportResumed(){ 104 transportListener.transportResumed(); 105 } 106 107 public Object narrow(Class target){ 108 if(target.isAssignableFrom(getClass())){ 109 return this; 110 } 111 return next.narrow(target); 112 } 113 114 public String getRemoteAddress() { 115 return next.getRemoteAddress(); 116 } 117 } 118 | Popular Tags |