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