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.processors;
8   
9   import org.mule.config.spring.parsers.assembly.BeanAssembler;
10  import org.mule.config.spring.parsers.assembly.BeanAssemblerFactory;
11  import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration;
12  
13  import org.w3c.dom.Element;
14  
15  /**
16   * This iterates over the child elements, generates beans, and sets them on the current bean via the
17   * setter given.  So presumably there's either a single child or the destination is a collection.
18   *
19   * <p>Since this handles the iteration over children explicitly you need to set the flag
20   * {@link org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate#MULE_NO_RECURSE}
21   * on the parser.
22   *
23   * @see org.mule.config.spring.parsers.processors.AbstractChildElementIterator - please read the
24   * documentation for that processor
25   */
26  public class NamedSetterChildElementIterator extends AbstractChildElementIterator
27  {
28  
29      private String setter;
30  
31      public NamedSetterChildElementIterator(String setter, BeanAssemblerFactory beanAssemblerFactory, PropertyConfiguration configuration)
32      {
33          super(beanAssemblerFactory, configuration);
34          this.setter = setter;
35      }
36  
37      protected void insertBean(BeanAssembler targetAssembler, Object childBean, Element parent, Element child)
38      {
39          targetAssembler.extendTarget(setter, setter, childBean);
40      }
41  
42  }