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