Java MBean getMBeanServerDelegateName()

Here you can find the source of getMBeanServerDelegateName()

Description

Lookup the server delegate name, which works for sure for Java 1.6 but maye not for Java 1.5.

License

Apache License

Return

the objectname of the MBeanServer delegate present in every MBeanServer

Declaration

private static ObjectName getMBeanServerDelegateName() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.management.*;

public class Main {
    /**//from   w w  w .  ja v a 2 s .c om
     * Lookup the server delegate name, which works for sure for Java 1.6 but maye not for Java 1.5.
     * This method should be removed when dropping Java 1.5 support
     * @return the objectname of the MBeanServer delegate present in every MBeanServer
     */
    private static ObjectName getMBeanServerDelegateName() {
        try {
            return MBeanServerDelegate.DELEGATE_NAME;
        } catch (NoSuchFieldError error) {
            // For Java 1.5 we return the fixed name
            return newObjectName("JMImplementation:type=MBeanServerDelegate");
        }
    }

    /**
     * Factory method for creating a new object name, mapping any checked {@link MalformedObjectNameException} to
     * a runtime exception ({@link IllegalArgumentException})
     * @param pName name to convert
     * @return the created object name
     */
    public static ObjectName newObjectName(String pName) {
        try {
            return new ObjectName(pName);
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException("Invalid object name " + pName, e);
        }
    }
}

Related

  1. getMBeanServer()
  2. getMBeanServer()
  3. getMBeanServerConnection(final JMXConnector connector)
  4. getMbeanServerConnection(final JMXConnector jmxConnector)
  5. getMBeanServerConnectionForJMXClient()
  6. getMBeanServerId(final MBeanServer aMBeanServer)
  7. getMBeanServerObjectName()
  8. getOperation(MBeanInfo info, String opName)
  9. getProxy(MBeanServerConnection connection, ObjectName objectName, final Class objectClass)