Coverage Report - org.mule.config.spring.parsers.specific.endpoint.support.ChildEndpointDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
ChildEndpointDefinitionParser
0%
0/22
0%
0/20
0
 
 1  
 /*
 2  
  * $Id: ChildEndpointDefinitionParser.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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  
 
 18  
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 19  
 import org.w3c.dom.Element;
 20  
 
 21  
 /**
 22  
  * A parser for "embedded" endpoints - ie inbound, outbound and response endpoints.
 23  
  * Because we have automatic String -> MuleEnpointURI conversion via property editors
 24  
  * this can be used in a variety of ways. It should work directly with a simple
 25  
  * String address attribute or, in combination with a child element (handled by
 26  
  * {@link ChildAddressDefinitionParser}, or embedded in
 27  
  * {@link AddressedEndpointDefinitionParser} for a more compact single-element
 28  
  * approach.
 29  
  * <p>
 30  
  * This class does support references to other endpoints.
 31  
  * </p>
 32  
  * TODO - check that references are global!
 33  
  */
 34  
 public class ChildEndpointDefinitionParser extends ChildDefinitionParser
 35  
 {
 36  
 
 37  
     public ChildEndpointDefinitionParser(Class endpoint)
 38  
     {
 39  0
         super("messageProcessor", endpoint);
 40  0
         addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
 41  0
         EndpointUtils.addProperties(this);
 42  0
         EndpointUtils.addPostProcess(this);
 43  0
     }
 44  
 
 45  
     @Override
 46  
     public BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, Class beanClass)
 47  
     {
 48  0
         BeanDefinitionBuilder builder = super.createBeanDefinitionBuilder(element, beanClass);
 49  0
         String global = element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
 50  0
         if (StringUtils.isNotBlank(global))
 51  
         {
 52  0
             builder.addConstructorArgReference(global);
 53  0
             builder.addDependsOn(global);
 54  
         }
 55  0
         return builder;
 56  
     }
 57  
 
 58  
     @Override
 59  
     public String getPropertyName(Element e)
 60  
     {
 61  0
         String parent = e.getParentNode().getLocalName().toLowerCase();
 62  0
         if (e.getLocalName() != null && e.getLocalName().toLowerCase().endsWith("inbound-endpoint"))
 63  
         {
 64  0
             return "messageSource";
 65  
         }
 66  0
         else if ("wire-tap".equals(parent) || "wire-tap-router".equals(parent))
 67  
         {
 68  0
             return "tap";
 69  
         }
 70  0
         else if ("binding".equals(parent) || "java-interface-binding".equals(parent)
 71  
                  || "publish-notifications".equals(parent) || "remote-dispatcher-agent".equals(parent))
 72  
         {
 73  0
             return "endpoint";
 74  
         }
 75  
         else
 76  
         {
 77  0
             return super.getPropertyName(e);
 78  
         }
 79  
     }
 80  
 
 81  
     @Override
 82  
     public String getBeanName(Element element)
 83  
     {
 84  0
         if (null != element.getAttributeNode(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF))
 85  
         {
 86  0
             return AutoIdUtils.uniqueValue("ref:"
 87  
                                            + element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF));
 88  
         }
 89  
         else
 90  
         {
 91  0
             return super.getBeanName(element);
 92  
         }
 93  
     }
 94  
 }