Coverage Report - org.mule.config.spring.parsers.specific.ForwardingRouterDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
ForwardingRouterDefinitionParser
0%
0/4
N/A
1
ForwardingRouterDefinitionParser$NullComponentPlaceholder
0%
0/6
N/A
1
 
 1  
 /*
 2  
  * $Id: ForwardingRouterDefinitionParser.java 11376 2008-03-16 17:44: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  
 package org.mule.config.spring.parsers.specific;
 11  
 
 12  
 import org.mule.component.simple.NullComponent;
 13  
 import org.mule.config.spring.parsers.delegate.AbstractSerialDelegatingDefinitionParser;
 14  
 import org.mule.config.spring.parsers.generic.GrandchildDefinitionParser;
 15  
 import org.mule.object.AbstractObjectFactory;
 16  
 import org.mule.object.SingletonObjectFactory;
 17  
 import org.mule.routing.inbound.ForwardingConsumer;
 18  
 
 19  
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 20  
 import org.springframework.beans.factory.xml.ParserContext;
 21  
 import org.w3c.dom.Element;
 22  
 
 23  
 /**
 24  
  * In addition to a ForwardingConsumer router, implicitly create a NullComponent service as a placeholder.
 25  
  *
 26  
  * We use AbstractSerialDelegatingDefinitionParser to be able to create 2 beans from a single element.
 27  
  * 
 28  
  * We use a ParentDefinitionParser for the NullComponent, because it needs to be set not on 
 29  
  * <inbound-router> (the surrounding element), but on <service> (one level up).
 30  
  * 
 31  
  *       <service name="BridgeOut">
 32  
  *           <inbound-router>
 33  
  *               <inbound-endpoint address="tcp://localhost:9994" transformer-ref="NoAction"/>
 34  
  *               <forwarding-router/>
 35  
  *           </inbound-router>
 36  
  *       </service>
 37  
  */
 38  
 public class ForwardingRouterDefinitionParser extends AbstractSerialDelegatingDefinitionParser
 39  
 {
 40  
     public ForwardingRouterDefinitionParser()
 41  
     {
 42  0
         super();
 43  0
         addDelegate(new RouterDefinitionParser(ForwardingConsumer.class));
 44  0
         addDelegate(new NullComponentPlaceholder());
 45  0
     }
 46  
     
 47  
     class NullComponentPlaceholder extends GrandchildDefinitionParser
 48  
     {
 49  
         public NullComponentPlaceholder()
 50  0
         {
 51  0
             super("componentFactory", SingletonObjectFactory.class);
 52  0
         }
 53  
         
 54  
         protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
 55  
         {
 56  0
             builder.addPropertyValue(AbstractObjectFactory.ATTRIBUTE_OBJECT_CLASS_NAME, NullComponent.class.getName());
 57  0
             super.parseChild(element, parserContext, builder);
 58  0
         }
 59  
     }
 60  
 }
 61  
 
 62