Coverage Report - org.mule.providers.soap.xfire.transport.MuleLocalTransport
 
Classes in this File Line Coverage Branch Coverage Complexity
MuleLocalTransport
57%
17/30
17%
1/6
1.455
 
 1  
 /*
 2  
  * $Id: MuleLocalTransport.java 7963 2007-08-21 08:53:15Z 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  
 import org.mule.umo.manager.UMOWorkManager;
 15  
 
 16  
 import org.apache.commons.logging.Log;
 17  
 import org.apache.commons.logging.LogFactory;
 18  
 import org.codehaus.xfire.MessageContext;
 19  
 import org.codehaus.xfire.service.Binding;
 20  
 import org.codehaus.xfire.service.Service;
 21  
 import org.codehaus.xfire.soap.Soap11;
 22  
 import org.codehaus.xfire.soap.Soap12;
 23  
 import org.codehaus.xfire.soap.SoapTransport;
 24  
 import org.codehaus.xfire.soap.SoapTransportHelper;
 25  
 import org.codehaus.xfire.soap.SoapVersion;
 26  
 import org.codehaus.xfire.transport.AbstractTransport;
 27  
 import org.codehaus.xfire.transport.Channel;
 28  
 import org.codehaus.xfire.transport.DefaultEndpoint;
 29  
 import org.codehaus.xfire.transport.MapSession;
 30  
 import org.codehaus.xfire.transport.Session;
 31  
 import org.codehaus.xfire.wsdl11.WSDL11Transport;
 32  
 
 33  
 /**
 34  
  * TODO document
 35  
  */
 36  
 public class MuleLocalTransport extends AbstractTransport implements SoapTransport, WSDL11Transport
 37  
 {
 38  
     public static final String SOAP11_HTTP_BINDING = "http://schemas.xmlsoap.org/soap/http";
 39  
     public static final String SOAP12_HTTP_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/";
 40  
     public static final String BINDING_ID = "urn:xfire:transport:local";
 41  
     public static final String URI_PREFIX = "xfire.local://";
 42  
 
 43  
     /**
 44  
      * logger used by this class
 45  
      */
 46  44
     protected transient Log logger = LogFactory.getLog(getClass());
 47  
 
 48  
     private Session session;
 49  
     private boolean maintainSession;
 50  
     protected final UMOWorkManager workManager;
 51  
 
 52  
     public MuleLocalTransport(UMOWorkManager workManager)
 53  
     {
 54  44
         super();
 55  44
         SoapTransportHelper.createSoapTransport(this);
 56  44
         this.workManager = workManager;
 57  44
     }
 58  
 
 59  
     public String getServiceURL(Service service)
 60  
     {
 61  20
         String ep = ((MuleInvoker) service.getInvoker()).getEndpoint().getEndpointURI().getAddress();
 62  20
         return ep + "/" + service.getSimpleName();
 63  
     }
 64  
 
 65  
     protected Channel createNewChannel(String uri)
 66  
     {
 67  32
         logger.debug("Creating new channel for uri: " + uri);
 68  
 
 69  32
         MuleLocalChannel c = new MuleLocalChannel(uri, this, session);
 70  32
         c.setWorkManager(workManager);
 71  32
         c.setEndpoint(new DefaultEndpoint());
 72  
 
 73  32
         return c;
 74  
     }
 75  
 
 76  
     public void setMaintainSession(boolean maintainSession)
 77  
     {
 78  0
         this.maintainSession = maintainSession;
 79  0
         resetSession();
 80  0
     }
 81  
 
 82  
     public void resetSession()
 83  
     {
 84  0
         if (maintainSession)
 85  
         {
 86  0
             session = new MapSession();
 87  
         }
 88  
         else
 89  
         {
 90  0
             session = null;
 91  
         }
 92  0
     }
 93  
 
 94  
     protected String getUriPrefix()
 95  
     {
 96  0
         return URI_PREFIX;
 97  
     }
 98  
 
 99  
     public String[] getSupportedBindings()
 100  
     {
 101  44
         return new String[]{BINDING_ID};
 102  
     }
 103  
 
 104  
     public String[] getKnownUriSchemes()
 105  
     {
 106  0
         return new String[]{URI_PREFIX};
 107  
     }
 108  
 
 109  
     public String getName()
 110  
     {
 111  20
         return "Local";
 112  
     }
 113  
 
 114  
     public String[] getSoapTransportIds()
 115  
     {
 116  0
         return new String[]{BINDING_ID};
 117  
     }
 118  
     
 119  
     public Binding findBinding(MessageContext context, Service service)
 120  
     {
 121  50
         SoapVersion version = context.getCurrentMessage().getSoapVersion();
 122  
 
 123  50
         if (version instanceof Soap11)
 124  
         {
 125  50
             return service.getBinding(SOAP11_HTTP_BINDING);
 126  
         }
 127  0
         else if (version instanceof Soap12)
 128  
         {
 129  0
             return service.getBinding(SOAP12_HTTP_BINDING);
 130  
         }
 131  
 
 132  0
         return super.findBinding(context, service);
 133  
     }
 134  
 }