Coverage Report - org.mule.config.spring.parsers.specific.endpoint.support.EndpointUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
EndpointUtils
0%
0/23
0%
0/10
2
EndpointUtils$1
0%
0/4
N/A
2
 
 1  
 /*
 2  
  * $Id: EndpointUtils.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  
 
 11  
 package org.mule.config.spring.parsers.specific.endpoint.support;
 12  
 
 13  
 import org.mule.config.spring.parsers.assembly.BeanAssembler;
 14  
 import org.mule.config.spring.parsers.MuleDefinitionParser;
 15  
 import org.mule.config.spring.parsers.PostProcessor;
 16  
 import org.mule.util.StringUtils;
 17  
 
 18  
 import org.w3c.dom.Element;
 19  
 import org.apache.commons.logging.Log;
 20  
 import org.apache.commons.logging.LogFactory;
 21  
 import org.springframework.beans.factory.xml.ParserContext;
 22  
 
 23  
 /**
 24  
  * Routines and constants common to the two endpoint definition parsers.
 25  
  *
 26  
  * @see ChildEndpointDefinitionParser
 27  
  * @see OrphanEndpointDefinitionParser
 28  
  */
 29  0
 public class EndpointUtils
 30  
 {
 31  
 
 32  0
     private static Log logger = LogFactory.getLog(EndpointUtils.class);
 33  
     public static final String CONNECTOR_ATTRIBUTE = "connector-ref";
 34  
     public static final String TRANSFORMERS_ATTRIBUTE = "transformer-refs";
 35  
     public static final String URI_BUILDER_ATTRIBUTE = "URIBuilder";
 36  
     public static final String ADDRESS_ATTRIBUTE = "address";
 37  
 
 38  
     private static void processTransformerDependencies(BeanAssembler assembler, Element element)
 39  
     {
 40  0
         if (StringUtils.isNotBlank(element.getAttribute(TRANSFORMERS_ATTRIBUTE)))
 41  
         {
 42  0
             String[] trans = StringUtils.split(element.getAttribute(TRANSFORMERS_ATTRIBUTE), " ,;");
 43  0
             for (int i = 0; i < trans.length; i++)
 44  
             {
 45  0
                 String ref = trans[i];
 46  0
                 if (logger.isDebugEnabled())
 47  
                 {
 48  0
                     logger.debug("transformer dep: " + ref);
 49  
                 }
 50  0
                 assembler.getBean().addDependsOn(ref);
 51  
             }
 52  
         }
 53  0
     }
 54  
 
 55  
     private static void processConnectorDependency(BeanAssembler assembler, Element element)
 56  
     {
 57  0
         if (StringUtils.isNotBlank(element.getAttribute(CONNECTOR_ATTRIBUTE)))
 58  
         {
 59  0
             String ref = element.getAttribute(CONNECTOR_ATTRIBUTE);
 60  0
             if (logger.isDebugEnabled())
 61  
             {
 62  0
                 logger.debug("connector dep: " + ref);
 63  
             }
 64  0
             assembler.getBean().addDependsOn(ref);
 65  
         }
 66  0
     }
 67  
 
 68  
     public static void addPostProcess(MuleDefinitionParser parser)
 69  
     {
 70  0
         parser.registerPostProcessor(new PostProcessor()
 71  0
         {
 72  
             public void postProcess(ParserContext unused, BeanAssembler assembler, Element element)
 73  
             {
 74  0
                 EndpointUtils.processConnectorDependency(assembler, element);
 75  0
                 EndpointUtils.processTransformerDependencies(assembler, element);
 76  0
             }
 77  
         });
 78  0
     }
 79  
 
 80  
     public static void addProperties(MuleDefinitionParser parser)
 81  
     {
 82  0
         parser.addAlias(ADDRESS_ATTRIBUTE, URI_BUILDER_ATTRIBUTE);
 83  0
         parser.addAlias("transformer", "transformers");
 84  0
         parser.addAlias("responseTransformer", "responseTransformers");
 85  0
         parser.addMapping("createConnector", "GET_OR_CREATE=0,ALWAYS_CREATE=1,NEVER_CREATE=2");
 86  0
     }
 87  
 
 88  
 }