1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.transport.soap.axis.config; |
8 | |
|
9 | |
import org.mule.config.spring.handlers.AbstractMuleNamespaceHandler; |
10 | |
import org.mule.config.spring.parsers.PreProcessor; |
11 | |
import org.mule.config.spring.parsers.assembly.MapEntryCombiner; |
12 | |
import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration; |
13 | |
import org.mule.config.spring.parsers.collection.ChildListEntryDefinitionParser; |
14 | |
import org.mule.config.spring.parsers.delegate.ParentContextDefinitionParser; |
15 | |
import org.mule.config.spring.parsers.processors.AttributeConcatenation; |
16 | |
import org.mule.config.spring.parsers.specific.ComponentDefinitionParser; |
17 | |
import org.mule.config.spring.parsers.specific.properties.ElementInNestedMapDefinitionParser; |
18 | |
import org.mule.config.spring.parsers.specific.properties.ListPropertyDefinitionParser; |
19 | |
import org.mule.config.spring.parsers.specific.properties.NestedListDefinitionParser; |
20 | |
import org.mule.config.spring.parsers.specific.properties.NestedMapWithAttributesDefinitionParser; |
21 | |
import org.mule.config.spring.parsers.specific.properties.SimplePropertyDefinitionParser; |
22 | |
import org.mule.module.cxf.SoapConstants; |
23 | |
import org.mule.transport.soap.axis.AxisConnector; |
24 | |
import org.mule.transport.soap.axis.AxisMessageReceiver; |
25 | |
import org.mule.transport.soap.axis.component.WebServiceWrapperComponent; |
26 | |
|
27 | |
import java.util.HashMap; |
28 | |
import java.util.Map; |
29 | |
|
30 | |
import org.apache.axis.constants.Style; |
31 | |
import org.apache.axis.constants.Use; |
32 | |
import org.w3c.dom.Element; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public class AxisNamespaceHandler extends AbstractMuleNamespaceHandler |
38 | |
{ |
39 | |
|
40 | |
public static final String PROPERTIES = "properties"; |
41 | 0 | public static final Map<String, String> USE_MAP = new HashMap<String, String>(); |
42 | 0 | public static final Map<String, String> STYLE_MAP = new HashMap<String, String>(); |
43 | |
|
44 | |
static |
45 | |
{ |
46 | 0 | USE_MAP.put("LITERAL", Use.LITERAL_STR); |
47 | 0 | USE_MAP.put("ENCODED", Use.ENCODED_STR); |
48 | |
|
49 | 0 | STYLE_MAP.put("DOCUMENT", Style.DOCUMENT_STR); |
50 | 0 | STYLE_MAP.put("MESSAGE", Style.MESSAGE_STR); |
51 | 0 | STYLE_MAP.put("RPC", Style.RPC_STR); |
52 | 0 | STYLE_MAP.put("WRAPPED", Style.WRAPPED_STR); |
53 | 0 | } |
54 | |
|
55 | |
|
56 | |
public void init() |
57 | |
{ |
58 | 0 | registerMetaTransportEndpoints(AxisConnector.AXIS).addMapping(AxisConnector.USE, USE_MAP).addMapping(AxisConnector.STYLE, STYLE_MAP); |
59 | 0 | registerConnectorDefinitionParser(AxisConnector.class); |
60 | 0 | registerBeanDefinitionParser("supported-scheme", new ChildListEntryDefinitionParser("supportedSchemes", "value")); |
61 | 0 | registerBeanDefinitionParser("soap-method", new ElementInNestedMapDefinitionParser(PROPERTIES, AxisConnector.SOAP_METHODS, "method")); |
62 | 0 | registerBeanDefinitionParser("soap-parameter", new SoapParameterDefinitionParser()); |
63 | 0 | registerBeanDefinitionParser("soap-return", new SoapReturnDefinitionParser()); |
64 | 0 | registerMuleBeanDefinitionParser("soap-service", new NestedListDefinitionParser(PROPERTIES, SoapConstants.SERVICE_INTERFACES, "interface")); |
65 | 0 | registerMuleBeanDefinitionParser("options", new NestedMapWithAttributesDefinitionParser(PROPERTIES, AxisMessageReceiver.AXIS_OPTIONS)); |
66 | 0 | registerMuleBeanDefinitionParser("option", new SimplePropertyDefinitionParser()); |
67 | 0 | registerMuleBeanDefinitionParser("bean-type", |
68 | |
new ParentContextDefinitionParser("connector", new ChildListEntryDefinitionParser(AxisMessageReceiver.BEAN_TYPES, "interface")) |
69 | |
.otherwise(new NestedListDefinitionParser(PROPERTIES, AxisMessageReceiver.BEAN_TYPES, "interface"))); |
70 | |
|
71 | 0 | registerBeanDefinitionParser("wrapper-component", new ComponentDefinitionParser(WebServiceWrapperComponent.class)); |
72 | 0 | } |
73 | |
|
74 | |
private static class SoapParameterDefinitionParser extends ListPropertyDefinitionParser |
75 | |
{ |
76 | |
|
77 | |
public static final String PARAMETER = "parameter"; |
78 | |
|
79 | |
public SoapParameterDefinitionParser() |
80 | |
{ |
81 | 0 | super(PARAMETER); |
82 | 0 | registerPreProcessor(new AttributeConcatenation(PARAMETER, ";", new String[]{PARAMETER, "type", "mode"})); |
83 | 0 | } |
84 | |
|
85 | |
} |
86 | |
|
87 | 0 | private static class SoapReturnDefinitionParser extends ListPropertyDefinitionParser |
88 | |
{ |
89 | |
|
90 | |
public SoapReturnDefinitionParser() |
91 | |
{ |
92 | 0 | super(MapEntryCombiner.VALUE); |
93 | 0 | registerPreProcessor(new PreProcessor() |
94 | 0 | { |
95 | |
public void preProcess(PropertyConfiguration config, Element element) |
96 | |
{ |
97 | 0 | element.setAttribute(MapEntryCombiner.VALUE, "return;" + element.getAttribute("type")); |
98 | 0 | } |
99 | |
}); |
100 | 0 | } |
101 | |
|
102 | |
} |
103 | |
|
104 | |
} |
105 | |
|
106 | |
|