Rio Project 4.2 API Documentation



org.rioproject.jmx
Class JMXConnectionUtil

java.lang.Object
  extended by org.rioproject.jmx.JMXConnectionUtil

public class JMXConnectionUtil
extends Object

Provides JMX connection utilities.

Author:
Dennis Reedy

Constructor Summary
JMXConnectionUtil()
           
 
Method Summary
static MBeanServerConnection attach(String id)
          Using the JMX Attach API , connect to a local Java Virtual Machine.
static void createJMXConnection(Configuration config)
          Create a JMXConnectorServer, bound to the RMI Registry created by an infrastructure service (Cybernode or Monitor).
static String getJMXServiceURL(int port, String hostAddress)
          Get a string that can be used as input for a JMXServiceURL
static String[] listIDs()
          Using the JMX Attach API , list the available local Java Virtual Machines.
static String[] listManagedVMs()
          Using the JMX Attach API , list the available local Java Virtual Machines.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMXConnectionUtil

public JMXConnectionUtil()
Method Detail

createJMXConnection

public static void createJMXConnection(Configuration config)
                                throws Exception
Create a JMXConnectorServer, bound to the RMI Registry created by an infrastructure service (Cybernode or Monitor).

If JMXConnectorServer has been created, return immediately. If the JMXConnectorServer needs to be created, it will be bound to the RMI Registry, and set the org.rioproject.jmxServiceURL system property.

This utility uses the RegistryUtil class to obtain the port to access the RMI Registry.

Configuration

This method supports the following configuration entries; where each configuration entry name is associated with the component name org.rioproject.jmx.

Parameters:
config - Configuration object to use
Throws:
Exception - If there are errors reading the configuration, or creating the JMXConnectorServer

getJMXServiceURL

public static String getJMXServiceURL(int port,
                                      String hostAddress)
Get a string that can be used as input for a JMXServiceURL

Parameters:
port - The port the MBeanServer has been created on
hostAddress - The host address the MBeanServer is running on
Returns:
A formatted string that can be used as input to create a JMXServiceURL

attach

public static MBeanServerConnection attach(String id)
                                    throws IOException,
                                           com.sun.tools.attach.AttachNotSupportedException,
                                           com.sun.tools.attach.AgentInitializationException,
                                           com.sun.tools.attach.AgentLoadException
Using the JMX Attach API , connect to a local Java Virtual Machine.

This utility requires Java 6 or greater.

Parameters:
id - The identifier used to connect to the Java Virtual Machine
Returns:
An MBeanServerConnection to the platform MBeanServer of the Java Virtual Machine identified, or null if the connection cannot be created.
Throws:
IOException - if the MBeanServerConnection cannot be created.
com.sun.tools.attach.AttachNotSupportedException - if the underlying provider either does not exist, or if the provider attempts to attach to a Java virtual machine with which it is not compatible.
com.sun.tools.attach.AgentInitializationException - thrown when an agent fails to initialize in the target Java virtual machine.
com.sun.tools.attach.AgentLoadException - when an agent cannot be loaded into the target Java virtual machine.

listIDs

public static String[] listIDs()
Using the JMX Attach API , list the available local Java Virtual Machines.

This utility requires Java 6 or greater.

Returns:
A String array of Java Virtual Machine IDs.

listManagedVMs

public static String[] listManagedVMs()
Using the JMX Attach API , list the available local Java Virtual Machines.

This utility requires Java 6 or greater.

Returns:
A String array of Java Virtual Machine IDs followed by the displayName of each discovered VirtualMachine

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.