KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > soap > SoapServiceFinder


1 /*
2  * $Id: SoapServiceFinder.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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.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 JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.TreeMap JavaDoc;
26
27 /**
28  * <code>SoapServiceFinder</code> finds a the connector service to use by checking
29  * the classpath for jars required for each of the soap connector implementations
30  *
31  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
32  * @version $Revision: 3798 $
33  */

34 public class SoapServiceFinder implements ConnectorServiceFinder
35 {
36     public ConnectorServiceDescriptor findService(String JavaDoc service, ConnectorServiceDescriptor csd)
37         throws ConnectorFactoryException
38     {
39         Map JavaDoc finders = new TreeMap JavaDoc();
40         PropertiesUtils.getPropertiesWithPrefix(csd.getProperties(), "finder.class", finders);
41
42         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
43         for (Iterator JavaDoc iterator = finders.entrySet().iterator(); iterator.hasNext();)
44         {
45             Map.Entry JavaDoc entry = (Map.Entry JavaDoc)iterator.next();
46             try
47             {
48                 ClassUtils.loadClass(entry.getValue().toString(), getClass());
49                 String JavaDoc protocol = getProtocolFromKey(entry.getKey().toString());
50                 return ConnectorFactory.getServiceDescriptor(protocol);
51             }
52             catch (ClassNotFoundException JavaDoc 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 JavaDoc getProtocolFromKey(String JavaDoc key)
63     {
64         return key.substring(key.lastIndexOf('.') + 1);
65     }
66 }
67
Popular Tags