1 /* 2 * $Id: JmxLegacySupport.java 7963 2007-08-21 08:53:15Z dirk.olmes $ 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.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 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 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 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 Set set = server.queryNames(null, null); 61 Set domains = new HashSet(); 62 for (Iterator it = set.iterator(); it.hasNext();) 63 { 64 ObjectName objectName = (ObjectName) it.next(); 65 domains.add(objectName.getDomain()); 66 } 67 return domains; 68 } 69 }