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