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