Coverage Report - org.mule.config.spring.parsers.specific.endpoint.support.ChildEndpointDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
ChildEndpointDefinitionParser
0%
0/18
0%
0/8
2
 
 1  
 /*
 2  
  * $Id: ChildEndpointDefinitionParser.java 11544 2008-04-08 21:12:32Z rossmason $
 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.specific.endpoint.support;
 12  
 
 13  
 import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser;
 14  
 import org.mule.config.spring.parsers.generic.AutoIdUtils;
 15  
 import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
 16  
 import org.mule.util.StringUtils;
 17  
 import org.mule.endpoint.AbstractEndpointBuilder;
 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  
  * A parser for "embedded" endpoints - ie inbound, outbound and response endpoints.
 25  
  * Because we have automatic String -> MuleEnpointURI conversion via property editors
 26  
  * this can be used in a variety of ways.  It should work directly with a simple String
 27  
  * address attribute or, in combination with a child element (handled by
 28  
  * {@link ChildAddressDefinitionParser},
 29  
  * or embedded in
 30  
  * {@link AddressedEndpointDefinitionParser}
 31  
  * for a more compact single-element approach.
 32  
  *
 33  
  * <p>This class does support references to other endpoints.</p>
 34  
  * TODO - check that references are global!
 35  
  */
 36  
 public class ChildEndpointDefinitionParser extends ChildDefinitionParser
 37  
 {
 38  
 
 39  
     public ChildEndpointDefinitionParser(Class endpoint)
 40  
     {
 41  0
         super("endpoint", endpoint);
 42  0
         addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
 43  0
         EndpointUtils.addProperties(this);
 44  0
         EndpointUtils.addPostProcess(this);
 45  0
     }
 46  
 
 47  
     // @Override
 48  
     public BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, Class beanClass)
 49  
     {
 50  0
         BeanDefinitionBuilder builder = super.createBeanDefinitionBuilder(element, beanClass);
 51  0
         String global = element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
 52  0
         if (StringUtils.isNotBlank(global))
 53  
         {
 54  0
             builder.addConstructorArgReference(global);
 55  0
             builder.addDependsOn(global);
 56  
         }
 57  0
         return builder;
 58  
     }
 59  
 
 60  
     // @Override
 61  
     public String getBeanName(Element element)
 62  
     {
 63  0
         if (null != element.getAttributeNode(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF))
 64  
         {
 65  0
             return AutoIdUtils.uniqueValue("ref:" + element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF));
 66  
         }
 67  
         else
 68  
         {
 69  0
             return super.getBeanName(element);
 70  
         }
 71  
     }
 72  
     
 73  
     //@Override
 74  
     protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
 75  
     {
 76  
         // Not sure if this is required. Adding for now for backwards compatability
 77  0
         if (element.getParentNode().getNodeName().equals("chaining-router")
 78  
             || element.getParentNode().getNodeName().equals("exception-based-router"))
 79  
         {
 80  0
             builder.addPropertyValue(AbstractEndpointBuilder.PROPERTY_REMOTE_SYNC, Boolean.TRUE);
 81  
         }
 82  
 
 83  0
         super.parseChild(element, parserContext, builder);
 84  0
     }
 85  
 
 86  
 }