Coverage Report - org.mule.module.management.support.JmxLegacySupport
 
Classes in this File Line Coverage Branch Coverage Complexity
JmxLegacySupport
0%
0/10
0%
0/2
1.333
 
 1  
 /*
 2  
  * $Id: JmxLegacySupport.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.support;
 11  
 
 12  
 import java.util.Collection;
 13  
 import java.util.HashSet;
 14  
 import java.util.Iterator;
 15  
 import java.util.Set;
 16  
 
 17  
 import javax.management.MBeanServer;
 18  
 import javax.management.MalformedObjectNameException;
 19  
 import javax.management.ObjectName;
 20  
 
 21  
 /**
 22  
  * Support class for JMX 1.1 based systems.
 23  
  */
 24  0
 public class JmxLegacySupport extends AbstractJmxSupport
 25  
 {
 26  
 
 27  
     /**
 28  
      * Uses simpler rules for escaping non-JMX compliant chars.
 29  
      * Much of the work has already been performed in {@link org.mule.util.ObjectNameHelper}.
 30  
      *
 31  
      * @param name value to escape for JMX compliance
 32  
      * @return value valid for JMX
 33  
      */
 34  
     public String escape(String name)
 35  
     {
 36  
         // do nothing at the moment, as ObjectNameHelper handles most of the conversion scenarios
 37  
         // kept as a placeholder and no-op to keep newer JMX classes from kicking in.
 38  0
         return name;
 39  
     }
 40  
 
 41  
 
 42  
     /**
 43  
      * For modern JMX implementation just delegate to a standard factory method.
 44  
      *
 45  
      * @param name object name
 46  
      * @return ObjectName for MBeanServer
 47  
      * @throws javax.management.MalformedObjectNameException
 48  
      *          for invalid names
 49  
      */
 50  
     public ObjectName getObjectName(String name) throws MalformedObjectNameException
 51  
     {
 52  0
         return new ObjectName(name);
 53  
     }
 54  
 
 55  
 
 56  
     /** {@inheritDoc} */
 57  
     protected Collection getDomains(final MBeanServer server)
 58  
     {
 59  
         // list all MBean names and collect unique domains
 60  0
         Set set = server.queryNames(null, null);
 61  0
         Set domains = new HashSet();
 62  0
         for (Iterator it = set.iterator(); it.hasNext();)
 63  
         {
 64  0
             ObjectName objectName = (ObjectName) it.next();
 65  0
             domains.add(objectName.getDomain());
 66  0
         }
 67  0
         return domains;
 68  
     }
 69  
 }