Coverage Report - org.mule.providers.soap.SoapServiceFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
SoapServiceFinder
0%
0/14
0%
0/2
3
 
 1  
 /*
 2  
  * $Id: SoapServiceFinder.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;
 12  
 
 13  
 import org.mule.providers.service.TransportFactory;
 14  
 import org.mule.providers.service.TransportFactoryException;
 15  
 import org.mule.providers.service.TransportServiceDescriptor;
 16  
 import org.mule.providers.service.TransportServiceException;
 17  
 import org.mule.providers.service.TransportServiceFinder;
 18  
 import org.mule.providers.soap.i18n.SoapMessages;
 19  
 import org.mule.util.ClassUtils;
 20  
 import org.mule.util.PropertiesUtils;
 21  
 
 22  
 import java.util.Iterator;
 23  
 import java.util.Map;
 24  
 import java.util.TreeMap;
 25  
 
 26  
 /**
 27  
  * <code>SoapServiceFinder</code> finds a the connector service to use by checking
 28  
  * the classpath for jars required for each of the soap connector implementations
 29  
  */
 30  0
 public class SoapServiceFinder implements TransportServiceFinder
 31  
 {
 32  
 
 33  
     public TransportServiceDescriptor findService(String service, TransportServiceDescriptor csd)
 34  
         throws TransportFactoryException
 35  
     {
 36  0
         Map finders = new TreeMap();
 37  0
         PropertiesUtils.getPropertiesWithPrefix(csd.getProperties(), "finder.class", finders);
 38  
 
 39  0
         StringBuffer buf = new StringBuffer();
 40  0
         for (Iterator iterator = finders.entrySet().iterator(); iterator.hasNext();)
 41  
         {
 42  0
             Map.Entry entry = (Map.Entry)iterator.next();
 43  
             try
 44  
             {
 45  0
                 ClassUtils.loadClass(entry.getValue().toString(), getClass());
 46  0
                 String protocol = getProtocolFromKey(entry.getKey().toString());
 47  0
                 return TransportFactory.getServiceDescriptor(protocol);
 48  
             }
 49  0
             catch (ClassNotFoundException e1)
 50  
             {
 51  0
                 buf.append(entry.getValue().toString()).append("(").append(entry.getKey().toString()).append(
 52  
                     ")").append(", ");
 53  
             }
 54  0
         }
 55  0
         throw new TransportServiceException(SoapMessages.couldNotFindSoapProvider(buf.toString()));
 56  
     }
 57  
 
 58  
     protected String getProtocolFromKey(String key)
 59  
     {
 60  0
         return key.substring(key.lastIndexOf('.') + 1);
 61  
     }
 62  
 }