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