KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > transport > http > HttpTransportFactory


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.transport.http;
19
20 import java.io.IOException JavaDoc;
21 import java.net.URI JavaDoc;
22 import java.util.Map JavaDoc;
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 /**
35  * @version $Revision$
36  */

37 public class HttpTransportFactory extends TransportFactory {
38     private static final Log log = LogFactory.getLog(HttpTransportFactory.class);
39
40     public TransportServer doBind(String JavaDoc brokerId, URI JavaDoc location) throws IOException JavaDoc {
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 JavaDoc getDefaultWireFormatType() {
53         return "xstream";
54     }
55
56     protected Transport createTransport(URI JavaDoc location, WireFormat wf) throws IOException JavaDoc {
57         TextWireFormat textWireFormat = asTextWireFormat(wf);
58         return new HttpClientTransport(textWireFormat, location);
59     }
60     
61     public Transport compositeConfigure(Transport transport, WireFormat format, Map JavaDoc 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