1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.config.spring.parsers.processors; |
8 | |
|
9 | |
import org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate; |
10 | |
import org.mule.config.spring.parsers.PostProcessor; |
11 | |
import org.mule.config.spring.parsers.assembly.BeanAssembler; |
12 | |
import org.mule.config.spring.parsers.assembly.BeanAssemblerFactory; |
13 | |
import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration; |
14 | |
import org.mule.config.spring.util.SpringXMLUtils; |
15 | |
|
16 | |
import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate; |
17 | |
import org.springframework.beans.factory.xml.ParserContext; |
18 | |
import org.w3c.dom.Element; |
19 | |
import org.w3c.dom.Node; |
20 | |
import org.w3c.dom.NodeList; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
public abstract class AbstractChildElementIterator implements PostProcessor |
51 | |
{ |
52 | |
|
53 | |
private BeanAssemblerFactory beanAssemblerFactory; |
54 | |
private PropertyConfiguration configuration; |
55 | |
|
56 | |
public AbstractChildElementIterator(BeanAssemblerFactory beanAssemblerFactory, PropertyConfiguration configuration) |
57 | 0 | { |
58 | 0 | this.beanAssemblerFactory = beanAssemblerFactory; |
59 | 0 | this.configuration = configuration; |
60 | 0 | } |
61 | |
|
62 | |
public void postProcess(ParserContext context, BeanAssembler assembler, Element element) |
63 | |
{ |
64 | 0 | NodeList children = element.getChildNodes(); |
65 | 0 | for (int i = 0; i < children.getLength(); ++i) |
66 | |
{ |
67 | 0 | Node child = children.item(i); |
68 | 0 | if (child.getNodeType() == Node.ELEMENT_NODE) |
69 | |
{ |
70 | 0 | processChildElement(context, assembler, element, (Element) child); |
71 | |
} |
72 | |
} |
73 | 0 | } |
74 | |
|
75 | |
protected void processChildElement(ParserContext context, BeanAssembler assembler, Element parent, Element child) |
76 | |
{ |
77 | 0 | Object childBean = null; |
78 | 0 | if (SpringXMLUtils.isBeansNamespace(child) |
79 | |
|| SpringXMLUtils.isLocalName(child, BeanDefinitionParserDelegate.REF_ELEMENT)) |
80 | |
{ |
81 | 0 | childBean = context.getDelegate().parsePropertySubElement(child, null); |
82 | |
} |
83 | |
else |
84 | |
{ |
85 | 0 | childBean = context.getDelegate().parseCustomElement(child, |
86 | |
assembler.getBean().getBeanDefinition()); |
87 | |
} |
88 | 0 | BeanAssembler targetAssembler = beanAssemblerFactory.newBeanAssembler(null, null, configuration, |
89 | |
assembler.getBean().getRawBeanDefinition()); |
90 | 0 | insertBean(targetAssembler, childBean, parent, child); |
91 | 0 | } |
92 | |
|
93 | |
protected abstract void insertBean(BeanAssembler targetAssembler, Object childBean, Element parent, Element child); |
94 | |
|
95 | |
} |