View Javadoc

1   /*
2    * $Id: ComponentDefinitionParser.java 11373 2008-03-15 05:03:10Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.config.spring.parsers.specific;
12  
13  import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser;
14  import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
15  
16  import org.springframework.beans.factory.support.BeanDefinitionBuilder;
17  import org.springframework.beans.factory.xml.ParserContext;
18  import org.w3c.dom.Element;
19  
20  public class ComponentDefinitionParser extends ChildDefinitionParser
21  {
22  
23      public ComponentDefinitionParser(Class clazz)
24      {
25          super("component", clazz);
26          this.singleton = true;
27          addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_CLASS);
28      }
29  
30      // @Override
31      protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
32      {
33          Element parent = (Element) element.getParentNode();
34          String serviceName = parent.getAttribute(ATTRIBUTE_NAME);
35          builder.addPropertyReference("service", serviceName);
36          super.parseChild(element, parserContext, builder);
37      }
38  }