KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jsr181 > xfire > JbiTransport


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

17 package org.apache.servicemix.jsr181.xfire;
18
19 import javax.jbi.component.ComponentContext;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23 import org.codehaus.xfire.handler.LocateBindingHandler;
24 import org.codehaus.xfire.service.Service;
25 import org.codehaus.xfire.soap.SoapTransport;
26 import org.codehaus.xfire.soap.handler.SoapBodyHandler;
27 import org.codehaus.xfire.transport.AbstractTransport;
28 import org.codehaus.xfire.transport.Channel;
29 import org.codehaus.xfire.transport.DefaultEndpoint;
30 import org.codehaus.xfire.wsdl11.WSDL11Transport;
31
32 /**
33  * Simple jbi transport, similar to local transport,
34  * but without soap encoding.
35  *
36  */

37 public class JbiTransport extends AbstractTransport implements WSDL11Transport, SoapTransport {
38
39     private static final Log log = LogFactory.getLog(JbiTransport.class);
40     
41     public final static String JavaDoc JBI_BINDING = "http://java.sun.com/xml/ns/jbi/binding/service+engine";
42     
43     private final static String JavaDoc URI_PREFIX = "urn:xfire:transport:jbi:";
44
45     private ComponentContext context;
46     
47     public JbiTransport(ComponentContext context) {
48         addInHandler(new LocateBindingHandler());
49         addInHandler(new SoapBodyHandler());
50         this.context = context;
51     }
52     
53     public String JavaDoc getName() {
54         return "JBI";
55     }
56     
57     public String JavaDoc getServiceURL(Service service) {
58         return "jbi://" + service.getName();
59     }
60
61     protected Channel createNewChannel(String JavaDoc uri) {
62         log.debug("Creating new channel for uri: " + uri);
63         JbiChannel c = new JbiChannel(uri, this);
64         c.setEndpoint(new DefaultEndpoint());
65         return c;
66     }
67
68     protected String JavaDoc getUriPrefix() {
69         return URI_PREFIX;
70     }
71
72     public String JavaDoc[] getSupportedBindings()
73     {
74         return new String JavaDoc[] { JBI_BINDING };
75     }
76
77     public String JavaDoc[] getKnownUriSchemes() {
78         return new String JavaDoc[] { "jbi://" };
79     }
80
81     public ComponentContext getContext() {
82         return context;
83     }
84     
85     public boolean equals(Object JavaDoc o) {
86         return o instanceof JbiTransport;
87     }
88     
89 }
90
91
Popular Tags