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