1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
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 | |
|
28 | |
|
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 | |
} |