Coverage Report - org.mule.providers.soap.xfire.transport.MuleUniversalTransport
 
Classes in this File Line Coverage Branch Coverage Complexity
MuleUniversalTransport
0%
0/21
0%
0/2
1.444
 
 1  
 /*
 2  
  * $Id: MuleUniversalTransport.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 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 CPAL v1.0
 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.mule.providers.soap.xfire.MuleInvoker;
 14  
 
 15  
 import org.apache.commons.logging.Log;
 16  
 import org.apache.commons.logging.LogFactory;
 17  
 import org.codehaus.xfire.MessageContext;
 18  
 import org.codehaus.xfire.service.Binding;
 19  
 import org.codehaus.xfire.service.Service;
 20  
 import org.codehaus.xfire.soap.Soap11;
 21  
 import org.codehaus.xfire.soap.Soap12;
 22  
 import org.codehaus.xfire.soap.SoapTransportHelper;
 23  
 import org.codehaus.xfire.soap.SoapVersion;
 24  
 import org.codehaus.xfire.transport.AbstractTransport;
 25  
 import org.codehaus.xfire.transport.Channel;
 26  
 import org.codehaus.xfire.transport.DefaultEndpoint;
 27  
 import org.codehaus.xfire.wsdl11.WSDL11Transport;
 28  
 
 29  
 /**
 30  
  * TODO document
 31  
  */
 32  
 public class MuleUniversalTransport extends AbstractTransport implements WSDL11Transport
 33  
 {
 34  
     public static final String SOAP11_HTTP_BINDING = "http://schemas.xmlsoap.org/soap/http";
 35  
     public static final String SOAP12_HTTP_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/";
 36  
     public static final String HTTP_BINDING = "http://www.w3.org/2004/08/wsdl/http";
 37  
     public static final String HTTP_TRANSPORT_NS = "http://schemas.xmlsoap.org/soap/mule";
 38  
     private static final String URI_PREFIX = "urn:xfire:transport:mule:";
 39  
 
 40  
     /**
 41  
      * logger used by this class
 42  
      */
 43  0
     protected transient Log logger = LogFactory.getLog(getClass());
 44  
 
 45  
     public MuleUniversalTransport()
 46  0
     {
 47  0
         SoapTransportHelper.createSoapTransport(this);
 48  0
     }
 49  
 
 50  
     protected Channel createNewChannel(String uri)
 51  
     {
 52  0
         logger.debug("Creating new channel for uri: " + uri);
 53  
 
 54  0
         MuleUniversalChannel c = new MuleUniversalChannel(uri, this);
 55  0
         c.setEndpoint(new DefaultEndpoint());
 56  
 
 57  0
         return c;
 58  
     }
 59  
 
 60  
     protected String getUriPrefix()
 61  
     {
 62  0
         return URI_PREFIX;
 63  
     }
 64  
 
 65  
     /**
 66  
      * Get the URL for a particular service.
 67  
      */
 68  
     public String getServiceURL(Service service)
 69  
     {
 70  
         //return "http://localhost/services/" + service.getSimpleName();
 71  0
         String ep = ((MuleInvoker) service.getInvoker()).getEndpoint().getEndpointURI().getAddress();
 72  0
         return ep + "/" + service.getSimpleName();
 73  
     }
 74  
 
 75  
     public String getTransportURI(Service service)
 76  
     {
 77  0
         return HTTP_TRANSPORT_NS;
 78  
     }
 79  
 
 80  
     public String[] getKnownUriSchemes()
 81  
     {
 82  0
         return new String[]{"http://", "https://", "jms://", "vm://", "xmpp://", "smtp://", "tcp://"};
 83  
     }
 84  
 
 85  
     public String[] getSupportedBindings()
 86  
     {
 87  0
         return new String[]{SOAP11_HTTP_BINDING, SOAP12_HTTP_BINDING};
 88  
     }
 89  
 
 90  
     public String getName()
 91  
     {
 92  0
         return "Mule";
 93  
     }
 94  
 
 95  
     public Binding findBinding(MessageContext context, Service service)
 96  
     {
 97  0
         SoapVersion version = context.getCurrentMessage().getSoapVersion();
 98  
 
 99  0
         if (version instanceof Soap11)
 100  
         {
 101  0
             return service.getBinding(SOAP11_HTTP_BINDING);
 102  
         }
 103  0
         else if (version instanceof Soap12)
 104  
         {
 105  0
             return service.getBinding(SOAP12_HTTP_BINDING);
 106  
         }
 107  
 
 108  0
         return super.findBinding(context, service);
 109  
     }
 110  
 }