1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transport.soap; |
12 | |
|
13 | |
import org.mule.api.registry.ServiceDescriptor; |
14 | |
import org.mule.api.registry.ServiceException; |
15 | |
import org.mule.api.registry.ServiceFinder; |
16 | |
import org.mule.transport.soap.i18n.SoapMessages; |
17 | |
import org.mule.util.ClassUtils; |
18 | |
import org.mule.util.PropertiesUtils; |
19 | |
|
20 | |
import java.util.Iterator; |
21 | |
import java.util.Map; |
22 | |
import java.util.Properties; |
23 | |
import java.util.TreeMap; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class SoapServiceFinder implements ServiceFinder |
30 | |
{ |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
public String findService(String service, ServiceDescriptor descriptor, Properties props) throws ServiceException |
36 | |
{ |
37 | 0 | Map finders = new TreeMap(); |
38 | 0 | PropertiesUtils.getPropertiesWithPrefix(props, "finder.class", finders); |
39 | |
|
40 | 0 | StringBuffer buf = new StringBuffer(); |
41 | 0 | for (Iterator iterator = finders.entrySet().iterator(); iterator.hasNext();) |
42 | |
{ |
43 | 0 | Map.Entry entry = (Map.Entry)iterator.next(); |
44 | |
try |
45 | |
{ |
46 | 0 | ClassUtils.loadClass(entry.getValue().toString(), getClass()); |
47 | 0 | return getProtocolFromKey(entry.getKey().toString()); |
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 ServiceException(SoapMessages.couldNotFindSoapProvider(buf.toString())); |
56 | |
} |
57 | |
|
58 | |
protected String getProtocolFromKey(String key) |
59 | |
{ |
60 | 0 | return key.substring(key.lastIndexOf('.') + 1); |
61 | |
} |
62 | |
} |