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