1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.parsers.delegate; |
12 | |
|
13 | |
import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser; |
14 | |
import org.mule.config.spring.parsers.MuleDefinitionParser; |
15 | |
import org.mule.config.spring.parsers.MuleDefinitionParserConfiguration; |
16 | |
import org.mule.config.spring.parsers.PostProcessor; |
17 | |
import org.mule.config.spring.parsers.PreProcessor; |
18 | |
import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration; |
19 | |
import org.mule.config.spring.parsers.assembly.configuration.SimplePropertyConfiguration; |
20 | |
import org.mule.config.spring.parsers.assembly.configuration.ValueMap; |
21 | |
import org.mule.config.spring.parsers.collection.DynamicAttributeDefinitionParser; |
22 | |
import org.mule.config.spring.parsers.generic.AutoIdUtils; |
23 | |
import org.mule.config.spring.util.SpringXMLUtils; |
24 | |
|
25 | |
import java.util.Map; |
26 | |
|
27 | |
import org.springframework.beans.factory.support.AbstractBeanDefinition; |
28 | |
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; |
29 | |
import org.springframework.beans.factory.xml.ParserContext; |
30 | |
import org.w3c.dom.Attr; |
31 | |
import org.w3c.dom.Element; |
32 | |
import org.w3c.dom.NamedNodeMap; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public class AllAttributeChildDefinitionParser |
38 | |
extends AbstractBeanDefinitionParser implements MuleDefinitionParser |
39 | |
{ |
40 | |
|
41 | |
private DynamicAttributeDefinitionParser delegate; |
42 | 0 | private PropertyConfiguration configuration = new SimplePropertyConfiguration(); |
43 | |
|
44 | |
public AllAttributeChildDefinitionParser(DynamicAttributeDefinitionParser delegate) |
45 | 0 | { |
46 | 0 | addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_ID); |
47 | 0 | addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_NAME); |
48 | 0 | this.delegate = delegate; |
49 | 0 | } |
50 | |
|
51 | |
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) |
52 | |
{ |
53 | 0 | NamedNodeMap attributes = element.getAttributes(); |
54 | 0 | for (int i = 0; i < attributes.getLength(); ++i) |
55 | |
{ |
56 | 0 | String name = SpringXMLUtils.attributeName((Attr) attributes.item(i)); |
57 | 0 | if (!isIgnored(name)) |
58 | |
{ |
59 | 0 | delegate.setAttributeName(name); |
60 | 0 | delegate.muleParse(element, parserContext); |
61 | |
} |
62 | |
} |
63 | 0 | return null; |
64 | |
} |
65 | |
|
66 | |
|
67 | |
public AbstractBeanDefinition muleParse(Element element, ParserContext parserContext) |
68 | |
{ |
69 | 0 | return parseInternal(element, parserContext); |
70 | |
} |
71 | |
|
72 | |
public MuleDefinitionParserConfiguration registerPreProcessor(PreProcessor preProcessor) |
73 | |
{ |
74 | 0 | delegate.registerPreProcessor(preProcessor); |
75 | 0 | return this; |
76 | |
} |
77 | |
|
78 | |
public MuleDefinitionParserConfiguration registerPostProcessor(PostProcessor postProcessor) |
79 | |
{ |
80 | 0 | delegate.registerPostProcessor(postProcessor); |
81 | 0 | return this; |
82 | |
} |
83 | |
|
84 | |
public MuleDefinitionParserConfiguration addReference(String propertyName) |
85 | |
{ |
86 | 0 | configuration.addReference(propertyName); |
87 | 0 | return this; |
88 | |
} |
89 | |
|
90 | |
public MuleDefinitionParserConfiguration addMapping(String propertyName, Map mappings) |
91 | |
{ |
92 | 0 | configuration.addMapping(propertyName, mappings); |
93 | 0 | return this; |
94 | |
} |
95 | |
|
96 | |
public MuleDefinitionParserConfiguration addMapping(String propertyName, String mappings) |
97 | |
{ |
98 | 0 | configuration.addMapping(propertyName, mappings); |
99 | 0 | return this; |
100 | |
} |
101 | |
|
102 | |
public MuleDefinitionParserConfiguration addMapping(String propertyName, ValueMap mappings) |
103 | |
{ |
104 | 0 | configuration.addMapping(propertyName, mappings); |
105 | 0 | return this; |
106 | |
} |
107 | |
|
108 | |
public MuleDefinitionParserConfiguration addAlias(String alias, String propertyName) |
109 | |
{ |
110 | 0 | configuration.addAlias(alias, propertyName); |
111 | 0 | return this; |
112 | |
} |
113 | |
|
114 | |
public MuleDefinitionParserConfiguration addCollection(String propertyName) |
115 | |
{ |
116 | 0 | configuration.addCollection(propertyName); |
117 | 0 | return this; |
118 | |
} |
119 | |
|
120 | |
public MuleDefinitionParserConfiguration addIgnored(String propertyName) |
121 | |
{ |
122 | 0 | configuration.addIgnored(propertyName); |
123 | 0 | return this; |
124 | |
} |
125 | |
|
126 | |
public MuleDefinitionParserConfiguration removeIgnored(String propertyName) |
127 | |
{ |
128 | 0 | configuration.removeIgnored(propertyName); |
129 | 0 | return this; |
130 | |
} |
131 | |
|
132 | |
public MuleDefinitionParserConfiguration setIgnoredDefault(boolean ignoreAll) |
133 | |
{ |
134 | 0 | configuration.setIgnoredDefault(ignoreAll); |
135 | 0 | return this; |
136 | |
} |
137 | |
|
138 | |
public String getAttributeMapping(String alias) |
139 | |
{ |
140 | 0 | return configuration.getAttributeMapping(alias); |
141 | |
} |
142 | |
|
143 | |
public boolean isCollection(String propertyName) |
144 | |
{ |
145 | 0 | return configuration.isCollection(propertyName); |
146 | |
} |
147 | |
|
148 | |
public boolean isIgnored(String propertyName) |
149 | |
{ |
150 | 0 | return configuration.isIgnored(propertyName); |
151 | |
} |
152 | |
|
153 | |
public boolean isBeanReference(String attributeName) |
154 | |
{ |
155 | 0 | return configuration.isReference(attributeName); |
156 | |
} |
157 | |
|
158 | |
public String translateName(String oldName) |
159 | |
{ |
160 | 0 | return configuration.translateName(oldName); |
161 | |
} |
162 | |
|
163 | |
public Object translateValue(String name, String value) |
164 | |
{ |
165 | 0 | return configuration.translateValue(name, value); |
166 | |
} |
167 | |
|
168 | |
public String getBeanName(Element element) |
169 | |
{ |
170 | 0 | return AutoIdUtils.getUniqueName(element, "all-attribute"); |
171 | |
} |
172 | |
|
173 | |
public MuleDefinitionParserConfiguration addBeanFlag(String flag) |
174 | |
{ |
175 | 0 | delegate.addBeanFlag(flag); |
176 | 0 | return this; |
177 | |
} |
178 | |
|
179 | |
} |