Coverage Report - org.mule.transport.cxf.wsdl.CxfWsdlMessageDispatcher
 
Classes in this File Line Coverage Branch Coverage Complexity
CxfWsdlMessageDispatcher
0%
0/16
0%
0/4
0
CxfWsdlMessageDispatcher$1
0%
0/17
0%
0/12
0
 
 1  
 /*
 2  
  * $Id: CxfWsdlMessageDispatcher.java 12200 2008-06-28 21:56:58Z dandiep $
 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.transport.cxf.wsdl;
 12  
 
 13  
 import org.mule.api.endpoint.OutboundEndpoint;
 14  
 import org.mule.transport.cxf.ClientWrapper;
 15  
 import org.mule.transport.cxf.CxfMessageDispatcher;
 16  
 import org.mule.util.StringUtils;
 17  
 
 18  
 import java.io.IOException;
 19  
 
 20  
 import javax.xml.namespace.QName;
 21  
 
 22  
 import org.apache.cxf.Bus;
 23  
 import org.apache.cxf.endpoint.Client;
 24  
 import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;
 25  
 
 26  
 /**
 27  
  * TODO document
 28  
  */
 29  
 public class CxfWsdlMessageDispatcher extends CxfMessageDispatcher
 30  
 {
 31  0
     private final static Object CLIENT_CREATION_LOCK = new Object();
 32  
     
 33  
     public CxfWsdlMessageDispatcher(OutboundEndpoint endpoint)
 34  
     {
 35  0
         super(endpoint);
 36  0
     }
 37  
 
 38  
     // @Override
 39  
     protected void doConnect() throws Exception
 40  
     {
 41  
         try
 42  
         {
 43  0
             wrapper = new ClientWrapper() {
 44  
 
 45  
                 @Override
 46  0
                 public void initialize() throws Exception, IOException
 47  
                 {
 48  0
                     String wsdlUrl = endpoint.getEndpointURI().getAddress();
 49  0
                     String serviceName = null;
 50  0
                     String portName = null;
 51  
 
 52  
                     // If the property specified an alternative WSDL url, use it
 53  0
                     if (endpoint.getProperty("wsdlLocation") != null && StringUtils.isNotBlank(endpoint.getProperty("wsdlLocation").toString()))
 54  
                     {
 55  0
                         wsdlUrl = (String) endpoint.getProperty("wsdlLocation");
 56  
                     }
 57  
                     
 58  
                     // If the property specified an alternative service, use it
 59  0
                     if (endpoint.getProperty("service") != null && StringUtils.isNotBlank(endpoint.getProperty("service").toString()))
 60  
                     {
 61  0
                         serviceName = (String) endpoint.getProperty("service");
 62  
                     }
 63  
                     
 64  
                     // If the property specified an alternative port, use it
 65  0
                     if (endpoint.getProperty("port") != null && StringUtils.isNotBlank(endpoint.getProperty("port").toString()))
 66  
                     {
 67  0
                         portName = (String) endpoint.getProperty("port");
 68  
                     }
 69  
                     
 70  
                     try
 71  
                     {
 72  0
                         this.client = createClient(bus, wsdlUrl, serviceName, portName);
 73  
     
 74  0
                         addMuleInterceptors();
 75  
                     }
 76  0
                     catch (Exception ex)
 77  
                     {
 78  0
                         disconnect();
 79  0
                         throw ex;
 80  0
                     }
 81  0
                 }
 82  
             };
 83  0
             wrapper.setBus(connector.getCxfBus());
 84  0
             wrapper.setEndpoint(endpoint);
 85  0
             wrapper.initialize();
 86  
         }
 87  0
         catch (Exception ex)
 88  
         {
 89  0
             disconnect();
 90  0
             throw ex;
 91  0
         }
 92  0
     }
 93  
 
 94  
     protected Client createClient(Bus bus, String wsdlUrl, String serviceName, String portName) throws Exception
 95  
     {
 96  0
         synchronized (CLIENT_CREATION_LOCK)
 97  
         {
 98  0
             DynamicClientFactory cf = DynamicClientFactory.newInstance(bus);
 99  0
             return cf.createClient(wsdlUrl, 
 100  
                (serviceName == null ? null : QName.valueOf(serviceName)), 
 101  
                (portName == null ? null : QName.valueOf(portName)));
 102  0
         }
 103  
     }
 104  
 }