1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.module.cxf.support; |
12 | |
|
13 | |
import java.lang.reflect.Method; |
14 | |
import java.util.ArrayList; |
15 | |
import java.util.List; |
16 | |
import java.util.logging.Level; |
17 | |
import java.util.logging.Logger; |
18 | |
|
19 | |
import javax.xml.namespace.QName; |
20 | |
import javax.xml.transform.Source; |
21 | |
|
22 | |
import org.apache.cxf.common.logging.LogUtils; |
23 | |
import org.apache.cxf.service.factory.ReflectionServiceFactoryBean; |
24 | |
import org.apache.cxf.service.factory.ServiceConstructionException; |
25 | |
import org.apache.cxf.service.model.EndpointInfo; |
26 | |
import org.apache.cxf.service.model.OperationInfo; |
27 | |
import org.apache.cxf.service.model.ServiceInfo; |
28 | |
import org.mule.module.cxf.i18n.CxfMessages; |
29 | |
|
30 | |
public class ProxyServiceFactoryBean extends ReflectionServiceFactoryBean |
31 | |
{ |
32 | |
|
33 | 0 | private static final Logger LOG = LogUtils.getLogger(ProxyServiceFactoryBean.class); |
34 | |
|
35 | |
public ProxyServiceFactoryBean() |
36 | 0 | { |
37 | 0 | getServiceConfigurations().add(0, new ProxyServiceConfiguration()); |
38 | |
|
39 | 0 | List<String> ignoredClasses = new ArrayList<String>(); |
40 | 0 | ignoredClasses.add("java.lang.Object"); |
41 | 0 | ignoredClasses.add("java.lang.Throwable"); |
42 | 0 | ignoredClasses.add("org.omg.CORBA_2_3.portable.ObjectImpl"); |
43 | 0 | ignoredClasses.add("org.omg.CORBA.portable.ObjectImpl"); |
44 | 0 | ignoredClasses.add("javax.ejb.EJBObject"); |
45 | 0 | ignoredClasses.add("javax.rmi.CORBA.Stub"); |
46 | 0 | setIgnoredClasses(ignoredClasses); |
47 | 0 | } |
48 | |
|
49 | |
@Override |
50 | |
protected void initializeWSDLOperations() |
51 | |
{ |
52 | 0 | if (getServiceClass().isAssignableFrom(ProxyService.class)) |
53 | |
{ |
54 | 0 | initializeWSDLOperationsForProvider(); |
55 | |
} |
56 | |
else |
57 | |
{ |
58 | 0 | super.initializeWSDLOperations(); |
59 | |
} |
60 | 0 | } |
61 | |
|
62 | |
protected void initializeWSDLOperationsForProvider() |
63 | |
{ |
64 | 0 | Class c = Source.class; |
65 | |
|
66 | 0 | if (getEndpointInfo() == null && isFromWsdl()) |
67 | |
{ |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | 0 | List<QName> enames = new ArrayList<QName>(); |
75 | 0 | for (ServiceInfo si : getService().getServiceInfos()) |
76 | |
{ |
77 | 0 | for (EndpointInfo ep : si.getEndpoints()) |
78 | |
{ |
79 | 0 | enames.add(ep.getName()); |
80 | |
} |
81 | |
} |
82 | 0 | LOG.log(Level.WARNING, "COULD_NOT_FIND_ENDPOINT", new ComponentNotFoundRuntimeException( |
83 | |
CxfMessages.couldNotFindEndpoint(getEndpointName(), enames))); |
84 | |
} |
85 | |
|
86 | |
try |
87 | |
{ |
88 | 0 | Method invoke = getServiceClass().getMethod("invoke", c); |
89 | |
|
90 | |
|
91 | 0 | for (ServiceInfo si : getService().getServiceInfos()) |
92 | |
{ |
93 | 0 | for (OperationInfo o : si.getInterface().getOperations()) |
94 | |
{ |
95 | 0 | getMethodDispatcher().bind(o, invoke); |
96 | |
} |
97 | |
} |
98 | |
} |
99 | 0 | catch (SecurityException e) |
100 | |
{ |
101 | 0 | throw new ServiceConstructionException(e); |
102 | |
} |
103 | 0 | catch (NoSuchMethodException e) |
104 | |
{ |
105 | 0 | throw new ServiceConstructionException(e); |
106 | 0 | } |
107 | |
|
108 | 0 | } |
109 | |
|
110 | |
} |