Rio Project 4.2 API Documentation



org.rioproject.jmx
Class JMXUtil

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

public class JMXUtil
extends Object

Provides utilities for using JMX.

Author:
Ming Fang, Dennis Reedy

Constructor Summary
JMXUtil()
           
 
Method Summary
static CompositeType createCompositeType(Map m, String compositeTypeName, String compositeTypeDescription)
          Create a CompositeType
static String getJMXConnection(Entry[] attributes)
          Get the String value found in the JMXConnection entry, or null if the attribute set does not include a JMXConnection
static Entry[] getJMXConnectionEntries(Configuration config)
          Get the attributes to add to a service's attribute collection
static String getJMXName(ServiceBeanContext context, String defaultDomain)
          Get the JMX name to use as a base name for the ObjectName.
static ObjectName getObjectName(ServiceBeanContext context, String defaultDomain, String name)
          Get an ObjectName with the following format : defaultDomain:type=,name=servicename, name=, id=
static ObjectName getObjectName(ServiceBeanContext context, String defaultDomain, String name, String id)
          Get an ObjectName with the following format :

defaultDomain:type=,name=servicename, name=, id=

static OpenType getOpenType(String classString, OpenType defaultType)
          Get the corresponding OpenType for a fully qualified class name
static
<T> T
getPlatformMXBeanProxy(MBeanServerConnection mbsc, String name, Class<T> mxBeanInterface)
          Get a platform MXBean proxy
static boolean isOpenType(String className)
          Determine if the class name is an OpenType
static Map toMap(Object data)
          Create a Map of accessor methods for the data object that are supported by OpenType.ALLOWED_CLASSNAMES
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMXUtil

public JMXUtil()
Method Detail

getPlatformMXBeanProxy

public static <T> T getPlatformMXBeanProxy(MBeanServerConnection mbsc,
                                           String name,
                                           Class<T> mxBeanInterface)
Get a platform MXBean proxy

Parameters:
mbsc - The MBeanServerConnection
name - The ObjectName to create
mxBeanInterface - The platform MXBean interface type to create
Returns:
A platform MXBean proxy

toMap

public static Map toMap(Object data)
                 throws IntrospectionException,
                        IllegalAccessException,
                        InvocationTargetException
Create a Map of accessor methods for the data object that are supported by OpenType.ALLOWED_CLASSNAMES

Parameters:
data - The data to map
Returns:
A Map of accessor methods for the data object that are supported by OpenType.ALLOWED_CLASSNAMES
Throws:
IntrospectionException - If an exception occurred during the introspection of an MBean
IllegalAccessException - If access permissions result reflecting on the MBean
InvocationTargetException - If the MBean cannot be instantiated

createCompositeType

public static CompositeType createCompositeType(Map m,
                                                String compositeTypeName,
                                                String compositeTypeDescription)
                                         throws OpenDataException
Create a CompositeType

Parameters:
m - A Map of accessor methods corresponding to open data types
compositeTypeName - The name to use for the composite type, must not be null or an empty string
compositeTypeDescription - The description to use for the composite type, must not be null or an empty string
Returns:
The created CompositeType
Throws:
OpenDataException - If the CompositeType cannot be created

getOpenType

public static OpenType getOpenType(String classString,
                                   OpenType defaultType)
Get the corresponding OpenType for a fully qualified class name

Parameters:
classString - A fully qualified class name, suitable for use with Class.forName(), must not be null
defaultType - The defaultOpenType to use
Returns:
the corresponding OpenType
Throws:
NullPointerException - if the classString argument is null
InvalidOpenTypeException - if the class described by the classString argument is not a valid open type

isOpenType

public static boolean isOpenType(String className)
Determine if the class name is an OpenType

Parameters:
className - A fully qualified class name, suitable for use with Class.forName(), must not be null
Returns:
If the class name is supported as an OpenType return true
See Also:
OpenType.ALLOWED_CLASSNAMES_LIST

getJMXName

public static String getJMXName(ServiceBeanContext context,
                                String defaultDomain)
Get the JMX name to use as a base name for the ObjectName. Key property list values should be appended to the value to create ObjectName instances. This method will check to see if the ServiceBeanConfig.JMX_NAME property exists, if it does not, the default domain will be used as a basis to create the name, and the property will be added to the context with the following format : defaultDomain:type=,name=servicename

Parameters:
context - The ServiceBeanContext, must not be null
defaultDomain - The default domain to use if the ServiceBeanConfig.JMX_NAME property is not found
Returns:
A String to use as a base name for the ObjectName. The returned value will have the name with the format of: jmxName,uuid=uuid-string

getObjectName

public static ObjectName getObjectName(ServiceBeanContext context,
                                       String defaultDomain,
                                       String name)
                                throws MalformedObjectNameException
Get an ObjectName with the following format : defaultDomain:type=,name=servicename, name=, id=

Parameters:
context - The ServiceBeanContext, must not be null
defaultDomain - The default domain to use if the ServiceBeanConfig.JMX_NAME property is not found
name - The name to use
Returns:
The created ObjectName
Throws:
MalformedObjectNameException - If the constructed name is malformed

getObjectName

public static ObjectName getObjectName(ServiceBeanContext context,
                                       String defaultDomain,
                                       String name,
                                       String id)
                                throws MalformedObjectNameException
Get an ObjectName with the following format :

defaultDomain:type=,name=servicename, name=, id=

Parameters:
context - The ServiceBeanContext, must not be null
defaultDomain - The default domain to use if the ServiceBeanConfig.JMX_NAME property is not found
name - The jmxName to use
id - The instanceID of the bean
Returns:
An ObjectName based on the ServiceBeanContext, defaultDomain, name and id
Throws:
MalformedObjectNameException - If the constructed name is malformed

getJMXConnectionEntries

public static Entry[] getJMXConnectionEntries(Configuration config)
                                       throws Exception
Get the attributes to add to a service's attribute collection

Parameters:
config - The configuration to use to optionally create an RMI Registry and obtain an optionally configured host address
Returns:
An array of Entrys. If the org.rioproject.jmxServiceURL system property exists (is not null) create an array of 2 attributes, one being JMXProtocolType with the protocol type set to JMXProtocolType.RMI, the other JMXProperty, set to the value of the property org.rioproject.jmxServiceURL. If the org.rioproject.jmxServiceURL property is not found, return a zero-length array. A new array is created each time.
Throws:
Exception - If the RMI registry or JMXConnection cannot be created

getJMXConnection

public static String getJMXConnection(Entry[] attributes)
Get the String value found in the JMXConnection entry, or null if the attribute set does not include a JMXConnection

Parameters:
attributes - An array of Entry attributes
Returns:
The JMX Connection String

Copyright © Rio Project.

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