1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
package org.mule.config.spring.parsers.collection; |
11 | |
|
12 | |
import org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate; |
13 | |
import org.mule.config.spring.parsers.generic.ChildDefinitionParser; |
14 | |
|
15 | |
import java.util.HashMap; |
16 | |
import java.util.Map; |
17 | |
|
18 | |
import org.springframework.beans.factory.config.MapFactoryBean; |
19 | |
import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
20 | |
import org.springframework.beans.factory.xml.ParserContext; |
21 | |
import org.w3c.dom.Element; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public class ChildMapDefinitionParser extends ChildDefinitionParser |
28 | |
{ |
29 | |
|
30 | |
public ChildMapDefinitionParser(String setterMethod) |
31 | |
{ |
32 | 0 | super(setterMethod, HashMap.class); |
33 | 0 | addBeanFlag(MuleHierarchicalBeanDefinitionParserDelegate.MULE_NO_RECURSE); |
34 | 0 | } |
35 | |
|
36 | |
protected Class getBeanClass(Element element) |
37 | |
{ |
38 | 0 | return MapFactoryBean.class; |
39 | |
} |
40 | |
|
41 | |
protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) |
42 | |
{ |
43 | 0 | super.parseChild(element, parserContext, builder); |
44 | 0 | Map parsedMap = parserContext.getDelegate().parseMapElement(element, builder.getRawBeanDefinition()); |
45 | 0 | builder.addPropertyValue("sourceMap", parsedMap); |
46 | 0 | builder.addPropertyValue("targetMapClass", super.getBeanClass(element)); |
47 | 0 | } |
48 | |
|
49 | |
} |