KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > soap > xfire > transport > MuleUniversalTransport


1 /*
2  * $Id: MuleUniversalTransport.java 4323 2006-12-19 15:55:15Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.soap.xfire.transport;
12
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15 import org.codehaus.xfire.MessageContext;
16 import org.codehaus.xfire.service.Binding;
17 import org.codehaus.xfire.service.Service;
18 import org.codehaus.xfire.soap.Soap11;
19 import org.codehaus.xfire.soap.Soap12;
20 import org.codehaus.xfire.soap.SoapTransportHelper;
21 import org.codehaus.xfire.soap.SoapVersion;
22 import org.codehaus.xfire.transport.AbstractTransport;
23 import org.codehaus.xfire.transport.Channel;
24 import org.codehaus.xfire.transport.DefaultEndpoint;
25 import org.codehaus.xfire.wsdl11.WSDL11Transport;
26 import org.mule.providers.soap.xfire.MuleInvoker;
27
28 /**
29  * TODO document
30  */

31 public class MuleUniversalTransport extends AbstractTransport implements WSDL11Transport
32 {
33     public static final String JavaDoc SOAP11_HTTP_BINDING = "http://schemas.xmlsoap.org/soap/http";
34     public static final String JavaDoc SOAP12_HTTP_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/";
35     public final static String JavaDoc HTTP_BINDING = "http://www.w3.org/2004/08/wsdl/http";
36     public final static String JavaDoc HTTP_TRANSPORT_NS = "http://schemas.xmlsoap.org/soap/mule";
37     private final static String JavaDoc URI_PREFIX = "urn:xfire:transport:mule:";
38
39     /**
40      * logger used by this class
41      */

42     protected transient Log logger = LogFactory.getLog(getClass());
43
44     public MuleUniversalTransport()
45     {
46         SoapTransportHelper.createSoapTransport(this);
47     }
48
49     protected Channel createNewChannel(String JavaDoc uri)
50     {
51         logger.debug("Creating new channel for uri: " + uri);
52
53         MuleUniversalChannel c = new MuleUniversalChannel(uri, this);
54         c.setEndpoint(new DefaultEndpoint());
55
56         return c;
57     }
58
59     protected String JavaDoc getUriPrefix()
60     {
61         return URI_PREFIX;
62     }
63
64     /**
65      * Get the URL for a particular service.
66      */

67     public String JavaDoc getServiceURL(Service service)
68     {
69         //return "http://localhost/services/" + service.getSimpleName();
70
String JavaDoc ep = ((MuleInvoker)service.getInvoker()).getEndpoint().getEndpointURI().getAddress();
71         return ep + "/" + service.getSimpleName();
72     }
73
74     public String JavaDoc getTransportURI(Service service)
75     {
76         return HTTP_TRANSPORT_NS;
77     }
78
79     public String JavaDoc[] getKnownUriSchemes()
80     {
81         return new String JavaDoc[]{"http://", "https://", "jms://", "vm://", "xmpp://", "smtp://", "tcp://"};
82     }
83
84     public String JavaDoc[] getSupportedBindings()
85     {
86         return new String JavaDoc[]{SOAP11_HTTP_BINDING, SOAP12_HTTP_BINDING};
87     }
88
89     public String JavaDoc getName()
90     {
91         return "Mule";
92     }
93
94     public Binding findBinding(MessageContext context, Service service)
95     {
96         SoapVersion version = context.getCurrentMessage().getSoapVersion();
97
98         if (version instanceof Soap11)
99         {
100             return service.getBinding(SOAP11_HTTP_BINDING);
101         }
102         else if (version instanceof Soap12)
103         {
104             return service.getBinding(SOAP12_HTTP_BINDING);
105         }
106
107         return super.findBinding(context, service);
108     }
109 }
110
Popular Tags