View Javadoc

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