Coverage Report - org.mule.config.spring.parsers.specific.endpoint.EndpointRefParser
 
Classes in this File Line Coverage Branch Coverage Complexity
EndpointRefParser
0%
0/11
0%
0/2
0
 
 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.specific.endpoint;
 8  
 
 9  
 import org.mule.config.spring.parsers.generic.ParentDefinitionParser;
 10  
 import org.mule.config.spring.parsers.processors.CheckExclusiveAttributes;
 11  
 import org.mule.util.StringUtils;
 12  
 
 13  
 import org.w3c.dom.Element;
 14  
 
 15  
 /**
 16  
  * Configures a reference to an endpoint on a parent bean.  This is typically used in configuration
 17  
  * where a reference to the actual endpoint is not wanted (i.e. Reply-To endpoints should be set as a string
 18  
  * on a message).
 19  
  *
 20  
  * Note that endpoint Reference elements should always have an 'address' and 'ref' attributes available.  These
 21  
  * are mutually exclusive.
 22  
  *
 23  
  * Any other attributes on the element processed by this parser will also be set on the parent object.
 24  
  */
 25  
 public class EndpointRefParser extends ParentDefinitionParser
 26  
 {
 27  
     public EndpointRefParser(String propertyName)
 28  0
     {
 29  0
         addAlias("address", propertyName);
 30  0
         addAlias("ref", propertyName);
 31  0
         addAlias("reference", propertyName);
 32  0
         registerPreProcessor(new CheckExclusiveAttributes(new String[][]{new String[]{"ref"}, new String[]{"address"}}));
 33  0
     }
 34  
 
 35  
 
 36  
 
 37  
     @Override
 38  
     protected void preProcess(Element element)
 39  
     {
 40  
         //This causes the Bean framework to process the "ref" as a string rather than a ref to another object
 41  0
         if(StringUtils.isNotEmpty(element.getAttribute("ref")))
 42  
         {
 43  0
             element.setAttribute("reference", element.getAttribute("ref"));
 44  0
             element.removeAttribute("ref");
 45  
         }
 46  0
         super.preProcess(element);
 47  
 
 48  0
     }
 49  
 }