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.collection;
8   
9   import org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate;
10  import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
11  
12  import java.util.ArrayList;
13  import java.util.List;
14  
15  import org.springframework.beans.factory.config.ListFactoryBean;
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 ChildListDefinitionParser extends ChildDefinitionParser
21  {
22  
23      public ChildListDefinitionParser(String setterMethod)
24      {
25          super(setterMethod, ArrayList.class);
26          addBeanFlag(MuleHierarchicalBeanDefinitionParserDelegate.MULE_NO_RECURSE);
27      }
28  
29      protected Class getBeanClass(Element element)
30      {
31          return ListFactoryBean.class;
32      }
33  
34      protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
35      {
36          super.parseChild(element, parserContext, builder);
37          List parsedList = parserContext.getDelegate().parseListElement(element, builder.getRawBeanDefinition());
38          builder.addPropertyValue("sourceList", parsedList);
39          builder.addPropertyValue("targetListClass", super.getBeanClass(element));
40      }
41  
42  }