01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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
38: WSDL11Transport, SoapTransport {
39:
40: public static final String JBI_BINDING = "http://java.sun.com/xml/ns/jbi/binding/service+engine";
41:
42: private static final Log LOG = LogFactory
43: .getLog(JbiTransport.class);
44:
45: private static final String URI_PREFIX = "urn:xfire:transport:jbi:";
46:
47: private ComponentContext context;
48:
49: public JbiTransport(ComponentContext context) {
50: addInHandler(new LocateBindingHandler());
51: addInHandler(new SoapBodyHandler());
52: this .context = context;
53: }
54:
55: public String getName() {
56: return "JBI";
57: }
58:
59: public String getServiceURL(Service service) {
60: return "jbi://" + service.getName();
61: }
62:
63: protected Channel createNewChannel(String uri) {
64: LOG.debug("Creating new channel for uri: " + uri);
65: JbiChannel c = new JbiChannel(uri, this );
66: c.setEndpoint(new DefaultEndpoint());
67: return c;
68: }
69:
70: protected String getUriPrefix() {
71: return URI_PREFIX;
72: }
73:
74: public String[] getSupportedBindings() {
75: return new String[] { JBI_BINDING };
76: }
77:
78: public String[] getKnownUriSchemes() {
79: return new String[] { "jbi://" };
80: }
81:
82: public ComponentContext getContext() {
83: return context;
84: }
85:
86: public boolean equals(Object o) {
87: return o instanceof JbiTransport;
88: }
89:
90: public int hashCode() {
91: return JbiTransport.class.hashCode();
92: }
93: }
|