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