Java MBean getMBeanServerConnectionForJMXClient()

Here you can find the source of getMBeanServerConnectionForJMXClient()

Description

get M Bean Server Connection For JMX Client

License

Apache License

Declaration

public static MBeanServerConnection getMBeanServerConnectionForJMXClient() throws IOException 

Method Source Code

//package com.java2s;
/*/*from w  w w  . j a  v  a 2  s .  c o m*/
 * Copyright 2008 Drips project Owners http://code.google.com/p/drips/
 * Saurabh Arora <saurabh.arora@gmail.com> And Prasen Mukherjee <prasen.bea@gmail.com>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.IOException;

import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

public class Main {
    public static MBeanServerConnection getMBeanServerConnectionForJMXClient() throws IOException {
        JMXServiceURL jmxURL = new JMXServiceURL(getJMXRMIServiceURL());
        JMXConnector _jmxConnector = JMXConnectorFactory.connect(jmxURL);
        return _jmxConnector.getMBeanServerConnection();
    }

    public static String getJMXRMIServiceURL() {
        String rmiregistryPort = getRMIRegistryPort();
        String rmiregistryHost = System.getProperty("drips.rmiregistry.host", "localhost");
        String rmiUrl = "rmi://" + rmiregistryHost + ":" + rmiregistryPort + "/dripsserver";
        String serviceURL = "service:jmx:rmi:///jndi/" + rmiUrl;
        return serviceURL;
    }

    public static String getRMIRegistryPort() {
        return System.getProperty("drips.rmiregistry.port", "9999");
    }
}

Related

  1. getMBeanServer()
  2. getMBeanServer()
  3. getMBeanServer()
  4. getMBeanServerConnection(final JMXConnector connector)
  5. getMbeanServerConnection(final JMXConnector jmxConnector)
  6. getMBeanServerDelegateName()
  7. getMBeanServerId(final MBeanServer aMBeanServer)
  8. getMBeanServerObjectName()
  9. getOperation(MBeanInfo info, String opName)