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 private static final Logger LOG = LogUtils.getLogger(ProxyServiceFactoryBean.class);
34
35 public ProxyServiceFactoryBean()
36 {
37 getServiceConfigurations().add(0, new ProxyServiceConfiguration());
38
39 List<String> ignoredClasses = new ArrayList<String>();
40 ignoredClasses.add("java.lang.Object");
41 ignoredClasses.add("java.lang.Throwable");
42 ignoredClasses.add("org.omg.CORBA_2_3.portable.ObjectImpl");
43 ignoredClasses.add("org.omg.CORBA.portable.ObjectImpl");
44 ignoredClasses.add("javax.ejb.EJBObject");
45 ignoredClasses.add("javax.rmi.CORBA.Stub");
46 setIgnoredClasses(ignoredClasses);
47 }
48
49 @Override
50 protected void initializeWSDLOperations()
51 {
52 if (getServiceClass().isAssignableFrom(ProxyService.class))
53 {
54 initializeWSDLOperationsForProvider();
55 }
56 else
57 {
58 super.initializeWSDLOperations();
59 }
60 }
61
62 protected void initializeWSDLOperationsForProvider()
63 {
64 Class c = Source.class;
65
66 if (getEndpointInfo() == null && isFromWsdl())
67 {
68
69
70
71
72
73
74 List<QName> enames = new ArrayList<QName>();
75 for (ServiceInfo si : getService().getServiceInfos())
76 {
77 for (EndpointInfo ep : si.getEndpoints())
78 {
79 enames.add(ep.getName());
80 }
81 }
82 LOG.log(Level.WARNING, "COULD_NOT_FIND_ENDPOINT", new ComponentNotFoundRuntimeException(
83 CxfMessages.couldNotFindEndpoint(getEndpointName(), enames)));
84 }
85
86 try
87 {
88 Method invoke = getServiceClass().getMethod("invoke", c);
89
90
91 for (ServiceInfo si : getService().getServiceInfos())
92 {
93 for (OperationInfo o : si.getInterface().getOperations())
94 {
95 getMethodDispatcher().bind(o, invoke);
96 }
97 }
98 }
99 catch (SecurityException e)
100 {
101 throw new ServiceConstructionException(e);
102 }
103 catch (NoSuchMethodException e)
104 {
105 throw new ServiceConstructionException(e);
106 }
107
108 }
109
110 }