View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config.spring.parsers.specific;
8   
9   import org.mule.api.config.MuleProperties;
10  import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
11  
12  import org.w3c.dom.Element;
13  
14  /**
15   * Extend {@link org.mule.config.spring.parsers.generic.ChildDefinitionParser} to include
16   * logic for identifying parent configuration element (since this only applies to "default"
17   * elements there's an ugliness here - contradicitions (non-default children of configuration)
18   * are avoided by the mule.xsd schema).
19   */
20  public class ConfigurationChildDefinitionParser extends ChildDefinitionParser
21  {
22  
23      /** Name of the mule:configuration element **/
24      public static final String CONFIGURATION = "configuration";
25  
26      public ConfigurationChildDefinitionParser(String setterMethod, Class clazz)
27      {
28          super(setterMethod, clazz);
29      }
30  
31      protected String getParentBeanName(Element element)
32      {
33          //The mule:configuration element is a fixed name element so we need to handle the
34          //special case here
35          if (CONFIGURATION.equals(element.getParentNode().getLocalName()))
36          {
37              return MuleProperties.OBJECT_MULE_CONFIGURATION;
38          }
39          else
40          {
41              return super.getParentBeanName(element);
42          }
43      }
44  
45  }