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