1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.parsers.collection; |
12 | |
|
13 | |
import org.mule.config.spring.parsers.assembly.BeanAssembler; |
14 | |
import org.mule.config.spring.parsers.generic.ChildDefinitionParser; |
15 | |
import org.mule.config.spring.util.SpringXMLUtils; |
16 | |
|
17 | |
import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
18 | |
import org.springframework.beans.factory.xml.ParserContext; |
19 | |
import org.w3c.dom.Element; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class ChildListEntryDefinitionParser extends ChildDefinitionParser |
27 | |
{ |
28 | |
|
29 | |
public static final String VALUE = "value"; |
30 | 0 | private boolean fromText = true; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public ChildListEntryDefinitionParser(String propertyName) |
38 | |
{ |
39 | 0 | super(propertyName, ListEntry.class); |
40 | 0 | setIgnoredDefault(true); |
41 | 0 | } |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
public ChildListEntryDefinitionParser(String propertyName, String attributeName) |
50 | |
{ |
51 | 0 | this(propertyName); |
52 | 0 | addAlias(attributeName, VALUE); |
53 | 0 | removeIgnored(attributeName); |
54 | 0 | fromText = false; |
55 | 0 | } |
56 | |
|
57 | |
protected void postProcess(ParserContext context, BeanAssembler assembler, Element element) |
58 | |
{ |
59 | 0 | if (fromText) |
60 | |
{ |
61 | 0 | assembler.extendBean(VALUE, SpringXMLUtils.getTextChild(element), false); |
62 | |
} |
63 | 0 | super.postProcess(context, assembler, element); |
64 | 0 | } |
65 | |
|
66 | |
protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) |
67 | |
{ |
68 | 0 | super.parseChild(element, parserContext, builder); |
69 | 0 | } |
70 | |
|
71 | |
public static class ListEntry |
72 | |
{ |
73 | |
|
74 | |
private Object value; |
75 | |
|
76 | |
public ListEntry() |
77 | |
{ |
78 | 0 | super(); |
79 | 0 | } |
80 | |
|
81 | |
public ListEntry(Object proxied) |
82 | |
{ |
83 | 0 | this(); |
84 | 0 | value = proxied; |
85 | 0 | } |
86 | |
|
87 | |
public Object getValue() |
88 | |
{ |
89 | 0 | return value; |
90 | |
} |
91 | |
|
92 | |
public void setValue(Object value) |
93 | |
{ |
94 | 0 | this.value = value; |
95 | 0 | } |
96 | |
} |
97 | |
|
98 | |
} |