01: /*
02: * $Id: ChildMapDefinitionParser.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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: * Creates a single Map and processes standard Spring sub elements. The map is injected
25: * into the parent object (the enclosing XML element).
26: */
27: public class ChildMapDefinitionParser extends ChildDefinitionParser {
28:
29: public ChildMapDefinitionParser(String setterMethod) {
30: super (setterMethod, HashMap.class);
31: addBeanFlag(MuleHierarchicalBeanDefinitionParserDelegate.MULE_NO_RECURSE);
32: }
33:
34: protected Class getBeanClass(Element element) {
35: return MapFactoryBean.class;
36: }
37:
38: protected void parseChild(Element element,
39: ParserContext parserContext, BeanDefinitionBuilder builder) {
40: super .parseChild(element, parserContext, builder);
41: Map parsedMap = parserContext.getDelegate().parseMapElement(
42: element, builder.getRawBeanDefinition());
43: builder.addPropertyValue("sourceMap", parsedMap);
44: builder.addPropertyValue("targetMapClass", super
45: .getBeanClass(element));
46: }
47:
48: }
|