1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.module.cxf.builder; |
12 | |
|
13 | |
import org.mule.module.cxf.CxfConstants; |
14 | |
import org.mule.module.cxf.support.CopyAttachmentInInterceptor; |
15 | |
import org.mule.module.cxf.support.CopyAttachmentOutInterceptor; |
16 | |
import org.mule.module.cxf.support.CxfUtils; |
17 | |
import org.mule.module.cxf.support.OutputPayloadInterceptor; |
18 | |
import org.mule.module.cxf.support.ProxySchemaValidationInInterceptor; |
19 | |
import org.mule.module.cxf.support.ProxyService; |
20 | |
import org.mule.module.cxf.support.ProxyServiceFactoryBean; |
21 | |
import org.mule.module.cxf.support.ResetStaxInterceptor; |
22 | |
import org.mule.module.cxf.support.ReversibleStaxInInterceptor; |
23 | |
|
24 | |
import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor; |
25 | |
import org.apache.cxf.databinding.stax.StaxDataBinding; |
26 | |
import org.apache.cxf.databinding.stax.StaxDataBindingFeature; |
27 | |
import org.apache.cxf.endpoint.Server; |
28 | |
import org.apache.cxf.frontend.ServerFactoryBean; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class ProxyServiceMessageProcessorBuilder extends AbstractInboundMessageProcessorBuilder |
40 | |
{ |
41 | |
private String payload; |
42 | |
|
43 | |
@Override |
44 | |
protected ServerFactoryBean createServerFactory() throws Exception |
45 | |
{ |
46 | 0 | ServerFactoryBean sfb = new ServerFactoryBean(); |
47 | 0 | sfb.setDataBinding(new StaxDataBinding()); |
48 | 0 | sfb.getFeatures().add(new StaxDataBindingFeature()); |
49 | 0 | sfb.setServiceFactory(new ProxyServiceFactoryBean()); |
50 | 0 | sfb.setServiceClass(ProxyService.class); |
51 | |
|
52 | 0 | addProxyInterceptors(sfb); |
53 | |
|
54 | 0 | return sfb; |
55 | |
} |
56 | |
|
57 | |
@Override |
58 | |
protected Class<?> getServiceClass() |
59 | |
{ |
60 | 0 | return ProxyService.class; |
61 | |
} |
62 | |
|
63 | |
@Override |
64 | |
protected void configureServer(Server server) |
65 | |
{ |
66 | 0 | if (isProxyEnvelope()) |
67 | |
{ |
68 | 0 | CxfUtils.removeInterceptor(server.getEndpoint().getBinding().getOutInterceptors(), SoapOutInterceptor.class.getName()); |
69 | |
} |
70 | |
|
71 | 0 | if (isValidationEnabled()) |
72 | |
{ |
73 | 0 | server.getEndpoint().getInInterceptors().add(new ProxySchemaValidationInInterceptor(getConfiguration().getCxfBus(), |
74 | |
server.getEndpoint().getService().getServiceInfos().get(0))); |
75 | |
} |
76 | 0 | } |
77 | |
|
78 | |
@Override |
79 | |
public boolean isProxy() |
80 | |
{ |
81 | 0 | return true; |
82 | |
} |
83 | |
|
84 | |
protected void addProxyInterceptors(ServerFactoryBean sfb) |
85 | |
{ |
86 | 0 | sfb.getOutInterceptors().add(new OutputPayloadInterceptor()); |
87 | 0 | sfb.getInInterceptors().add(new CopyAttachmentInInterceptor()); |
88 | 0 | sfb.getOutInterceptors().add(new CopyAttachmentOutInterceptor()); |
89 | |
|
90 | 0 | if (isProxyEnvelope()) |
91 | |
{ |
92 | 0 | sfb.getInInterceptors().add(new ReversibleStaxInInterceptor()); |
93 | 0 | sfb.getInInterceptors().add(new ResetStaxInterceptor()); |
94 | |
} |
95 | 0 | } |
96 | |
|
97 | |
public boolean isProxyEnvelope() |
98 | |
{ |
99 | 0 | return CxfConstants.PAYLOAD_ENVELOPE.equals(payload); |
100 | |
} |
101 | |
|
102 | |
public String getPayload() |
103 | |
{ |
104 | 0 | return payload; |
105 | |
} |
106 | |
|
107 | |
public void setPayload(String payload) |
108 | |
{ |
109 | 0 | this.payload = payload; |
110 | 0 | } |
111 | |
|
112 | |
} |