01: /*
02: * $Id: NestedMapDefinitionParser.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:
11: package org.mule.config.spring.parsers.specific.properties;
12:
13: import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser;
14: import org.mule.config.spring.parsers.assembly.MapEntryCombiner;
15: import org.mule.config.spring.parsers.collection.ChildSingletonMapDefinitionParser;
16: import org.mule.config.spring.parsers.delegate.AbstractSingleParentFamilyDefinitionParser;
17: import org.mule.config.spring.parsers.processors.AddAttribute;
18:
19: /**
20: * This extends a map that is itself a property (with key mapKey). It does not have any
21: * container element.
22: */
23: public class NestedMapDefinitionParser extends
24: AbstractSingleParentFamilyDefinitionParser {
25:
26: // we use this so that "key" can be used as the attribute name!
27: public static final String HIDDEN_KEY = "hiddenKey";
28:
29: public NestedMapDefinitionParser(String mapSetter, String mapKey) {
30: addDelegate(new ChildSingletonMapDefinitionParser(mapSetter))
31: .registerPreProcessor(
32: new AddAttribute(HIDDEN_KEY, mapKey))
33: .addCollection(mapSetter)
34: .setIgnoredDefault(true)
35: .addAlias(HIDDEN_KEY, MapEntryCombiner.KEY)
36: .removeIgnored(HIDDEN_KEY)
37: .addIgnored(
38: AbstractMuleBeanDefinitionParser.ATTRIBUTE_NAME);
39: addChildDelegate(new SimplePropertyDefinitionParser())
40: .addIgnored(HIDDEN_KEY)
41: .addIgnored(
42: AbstractMuleBeanDefinitionParser.ATTRIBUTE_NAME);
43: }
44:
45: }
|