Coverage Report - org.mule.module.management.config.JmxAgentDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
JmxAgentDefinitionParser
0%
0/18
0%
0/6
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.module.management.config;
 8  
 
 9  
 import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser;
 10  
 import org.mule.config.spring.parsers.assembly.BeanAssembler;
 11  
 import org.mule.config.spring.parsers.processors.ProvideDefaultNameFromElement;
 12  
 import org.mule.module.management.agent.JmxAgentConfigurer;
 13  
 import org.mule.util.StringUtils;
 14  
 
 15  
 import java.util.HashMap;
 16  
 import java.util.Map;
 17  
 
 18  
 import org.springframework.beans.factory.xml.ParserContext;
 19  
 import org.w3c.dom.Element;
 20  
 import org.w3c.dom.Node;
 21  
 import org.w3c.dom.NodeList;
 22  
 
 23  
 public class JmxAgentDefinitionParser extends AbstractMuleBeanDefinitionParser
 24  
 {
 25  
     public static final String CONNECTOR_SERVER = "connector-server";
 26  
 
 27  
     public JmxAgentDefinitionParser()
 28  0
     {
 29  0
         singleton = true;
 30  0
         addAlias("server", "mBeanServer");
 31  0
         registerPreProcessor(new ProvideDefaultNameFromElement());
 32  0
     }
 33  
 
 34  
     protected Class<?> getBeanClass(Element element)
 35  
     {
 36  0
         return JmxAgentConfigurer.class;
 37  
     }
 38  
 
 39  
     @Override
 40  
     protected void postProcess(ParserContext context, BeanAssembler assembler, Element element)
 41  
     {
 42  0
         NodeList childNodes = element.getChildNodes();
 43  0
         for (int i = 0; i < childNodes.getLength(); i++)
 44  
         {
 45  0
             Node node = childNodes.item(i);
 46  0
             if (CONNECTOR_SERVER.equals(node.getLocalName()))
 47  
             {
 48  0
                 assembler.extendBean("connectorServerUrl", ((Element) node).getAttribute("url"), false);
 49  0
                 String rebind = ((Element) node).getAttribute("rebind");
 50  
 
 51  0
                 if (!StringUtils.isEmpty(rebind))
 52  
                 {
 53  0
                     Map<String, String> csProps = new HashMap<String, String>();
 54  0
                     csProps.put("jmx.remote.jndi.rebind", rebind);
 55  0
                     assembler.extendBean("connectorServerProperties", csProps, false);
 56  
                 }
 57  
             }
 58  
         }
 59  
 
 60  0
         super.postProcess(context, assembler, element);
 61  0
     }
 62  
 
 63  
 }