1 18 package org.apache.activemq.transport.http; 19 20 import java.io.IOException ; 21 import java.net.URI ; 22 import java.util.Map ; 23 24 import org.apache.activemq.transport.Transport; 25 import org.apache.activemq.transport.TransportFactory; 26 import org.apache.activemq.transport.TransportLogger; 27 import org.apache.activemq.transport.TransportServer; 28 import org.apache.activemq.transport.util.TextWireFormat; 29 import org.apache.activemq.transport.xstream.XStreamWireFormat; 30 import org.apache.activemq.wireformat.WireFormat; 31 import org.apache.commons.logging.Log; 32 import org.apache.commons.logging.LogFactory; 33 34 37 public class HttpTransportFactory extends TransportFactory { 38 private static final Log log = LogFactory.getLog(HttpTransportFactory.class); 39 40 public TransportServer doBind(String brokerId, URI location) throws IOException { 41 return new HttpTransportServer(location); 42 } 43 44 protected TextWireFormat asTextWireFormat(WireFormat wireFormat) { 45 if (wireFormat instanceof TextWireFormat) { 46 return (TextWireFormat) wireFormat; 47 } 48 log.trace("Not created with a TextWireFormat: " + wireFormat); 49 return new XStreamWireFormat(); 50 } 51 52 protected String getDefaultWireFormatType() { 53 return "xstream"; 54 } 55 56 protected Transport createTransport(URI location, WireFormat wf) throws IOException { 57 TextWireFormat textWireFormat = asTextWireFormat(wf); 58 return new HttpClientTransport(textWireFormat, location); 59 } 60 61 public Transport compositeConfigure(Transport transport, WireFormat format, Map options) { 62 HttpClientTransport httpTransport = (HttpClientTransport) super.compositeConfigure(transport, format, options); 63 transport = httpTransport; 64 if( httpTransport.isTrace() ) { 65 transport = new TransportLogger(httpTransport); 66 } 67 return transport; 68 } 69 70 } 71 | Popular Tags |