1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.config.spring.parsers.delegate; |
8 | |
|
9 | |
import org.mule.config.spring.parsers.MuleChildDefinitionParser; |
10 | |
import org.mule.config.spring.parsers.MuleDefinitionParser; |
11 | |
import org.mule.config.spring.parsers.MuleDefinitionParserConfiguration; |
12 | |
|
13 | |
import org.springframework.beans.factory.support.AbstractBeanDefinition; |
14 | |
import org.springframework.beans.factory.xml.ParserContext; |
15 | |
import org.w3c.dom.Element; |
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public abstract class AbstractSingleParentFamilyDefinitionParser |
24 | |
extends AbstractFirstResultSerialDefinitionParser |
25 | |
{ |
26 | |
|
27 | |
public AbstractSingleParentFamilyDefinitionParser() |
28 | |
{ |
29 | 0 | super(); |
30 | 0 | } |
31 | |
|
32 | |
public AbstractSingleParentFamilyDefinitionParser(boolean doReset) |
33 | |
{ |
34 | 0 | super(doReset); |
35 | 0 | } |
36 | |
|
37 | |
protected MuleChildDefinitionParser addChildDelegate(MuleChildDefinitionParser delegate) |
38 | |
{ |
39 | 0 | return (MuleChildDefinitionParser) super.addDelegate(delegate); |
40 | |
} |
41 | |
|
42 | |
protected MuleDefinitionParserConfiguration addDelegate(MuleDefinitionParser delegate) |
43 | |
{ |
44 | 0 | if (size() > 0) |
45 | |
{ |
46 | 0 | return addDelegateAsChild(delegate); |
47 | |
} |
48 | |
else |
49 | |
{ |
50 | 0 | return super.addDelegate(delegate); |
51 | |
} |
52 | |
} |
53 | |
|
54 | |
protected MuleDefinitionParserConfiguration addDelegateAsChild(MuleDefinitionParser delegate) |
55 | |
{ |
56 | 0 | if (delegate instanceof MuleChildDefinitionParser) |
57 | |
{ |
58 | 0 | return addChildDelegate((MuleChildDefinitionParser) delegate); |
59 | |
} |
60 | |
else |
61 | |
{ |
62 | 0 | throw new IllegalStateException("Children must implement child interface"); |
63 | |
} |
64 | |
} |
65 | |
|
66 | |
protected AbstractBeanDefinition doSingleBean(int index, MuleDefinitionParser parser, |
67 | |
Element element, ParserContext parserContext) |
68 | |
{ |
69 | 0 | if (0 != index) |
70 | |
{ |
71 | 0 | ((MuleChildDefinitionParser) parser).forceParent(firstDefinition); |
72 | |
|
73 | |
|
74 | 0 | ((MuleChildDefinitionParser) parser).getTargetPropertyConfiguration().setIgnoredDefault(false); |
75 | |
} |
76 | 0 | return super.doSingleBean(index, parser, element, parserContext); |
77 | |
} |
78 | |
|
79 | |
} |