Coverage Report - org.mule.module.management.config.JmxAgentDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
JmxAgentDefinitionParser
67%
12/18
50%
3/6
2
 
 1  
 /*
 2  
  * $Id: JmxAgentDefinitionParser.java 11234 2008-03-06 23:44:34Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.JmxAgent;
 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  6
     {
 32  6
         singleton = true;
 33  6
         addAlias("server", "mBeanServer");
 34  6
         registerPreProcessor(new ProvideDefaultNameFromElement());
 35  6
     }
 36  
 
 37  
     protected Class getBeanClass(Element element)
 38  
     {
 39  4
         return JmxAgent.class;
 40  
     }
 41  
 
 42  
     protected void postProcess(ParserContext context, BeanAssembler assembler, Element element)
 43  
     {
 44  4
         NodeList childNodes = element.getChildNodes();
 45  16
         for (int i = 0; i < childNodes.getLength(); i++) {
 46  12
             Node node = childNodes.item(i);
 47  12
             if (CONNECTOR_SERVER.equals(node.getLocalName())) {
 48  0
                 assembler.extendBean("connectorServerUrl", ((Element) node).getAttribute("url"), false);
 49  0
                 String rebind = ((Element) node).getAttribute("rebind");
 50  0
                 if (!StringUtils.isEmpty(rebind)) {
 51  0
                     Map csProps = new HashMap();
 52  0
                     csProps.put("jmx.remote.jndi.rebind", rebind);
 53  0
                     assembler.extendBean("connectorServerProperties", csProps, false);
 54  
                 }
 55  
             }
 56  
         }
 57  4
         super.postProcess(context, assembler, element);
 58  4
     }
 59  
 
 60  
 }