1 10 11 package org.mule.providers.soap; 12 13 import org.mule.config.i18n.Message; 14 import org.mule.config.i18n.Messages; 15 import org.mule.providers.service.ConnectorFactory; 16 import org.mule.providers.service.ConnectorFactoryException; 17 import org.mule.providers.service.ConnectorServiceDescriptor; 18 import org.mule.providers.service.ConnectorServiceException; 19 import org.mule.providers.service.ConnectorServiceFinder; 20 import org.mule.util.ClassUtils; 21 import org.mule.util.PropertiesUtils; 22 23 import java.util.Iterator ; 24 import java.util.Map ; 25 import java.util.TreeMap ; 26 27 34 public class SoapServiceFinder implements ConnectorServiceFinder 35 { 36 public ConnectorServiceDescriptor findService(String service, ConnectorServiceDescriptor csd) 37 throws ConnectorFactoryException 38 { 39 Map finders = new TreeMap (); 40 PropertiesUtils.getPropertiesWithPrefix(csd.getProperties(), "finder.class", finders); 41 42 StringBuffer buf = new StringBuffer (); 43 for (Iterator iterator = finders.entrySet().iterator(); iterator.hasNext();) 44 { 45 Map.Entry entry = (Map.Entry )iterator.next(); 46 try 47 { 48 ClassUtils.loadClass(entry.getValue().toString(), getClass()); 49 String protocol = getProtocolFromKey(entry.getKey().toString()); 50 return ConnectorFactory.getServiceDescriptor(protocol); 51 } 52 catch (ClassNotFoundException e1) 53 { 54 buf.append(entry.getValue().toString()).append("(").append(entry.getKey().toString()).append( 55 ")").append(", "); 56 } 57 } 58 throw new ConnectorServiceException(new Message(Messages.COULD_NOT_FIND_SOAP_PROVIDER_X, 59 buf.toString())); 60 } 61 62 protected String getProtocolFromKey(String key) 63 { 64 return key.substring(key.lastIndexOf('.') + 1); 65 } 66 } 67 | Popular Tags |