View Javadoc

1   /*
2    * $Id: ServiceDefinitionParser.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.generic.OrphanDefinitionParser;
14  import org.mule.config.spring.parsers.processors.ProvideDefaultName;
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 ServiceDefinitionParser extends OrphanDefinitionParser
21  {
22  
23      // for custom services
24      public ServiceDefinitionParser()
25      {
26          super(true);
27          registerPreProcessor(new ProvideDefaultName("service"));
28      }
29  
30      public ServiceDefinitionParser(Class clazz)
31      {
32          super(clazz, true);
33          registerPreProcessor(new ProvideDefaultName("service"));
34      }
35  
36      @java.lang.Override
37      protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
38      {
39          Element parent = (Element) element.getParentNode();
40          String modelName = parent.getAttribute(ATTRIBUTE_NAME);
41          builder.addPropertyReference("model", modelName);
42          super.doParse(element, parserContext, builder);
43      }
44  
45  }