com.palantir.opensource.sysmon.util
Class JMXUtils

java.lang.Object
  extended by com.palantir.opensource.sysmon.util.JMXUtils

public final class JMXUtils
extends Object

A small collection of utility methods to simplify bean registration and removal.

See Also:
Java Management Extensions (JMX), MBeanServer

Method Summary
static void prettyPrintMbean(ObjectName mbean)
          Prints out all the attributes for the passed JMX MBean
static void registerMBean(Object mbean, String objectName)
          Simple method to register a bean with the server.
static void unregisterMBeanCatchAndLogExceptions(String objectName)
          Unconditionally attempts to unregister the specified MX Bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerMBean

public static void registerMBean(Object mbean,
                                 String objectName)
                          throws JMException
Simple method to register a bean with the server. The server used is the one returned by ManagementFactory.getPlatformMBeanServer(). This method unconditionally registers the passed bean by unregistering any existing bean at the specified objectName.

Parameters:
mbean - The MBean to be mounted on the server.
objectName - the path to mount the MBean at.
Throws:
JMException - upon error with JMX server operations

unregisterMBeanCatchAndLogExceptions

public static void unregisterMBeanCatchAndLogExceptions(String objectName)
Unconditionally attempts to unregister the specified MX Bean. Logs any exceptions at level Level.ERROR via log4j.

Parameters:
objectName - String path to the bean to be removed.
See Also:
Log4J

prettyPrintMbean

public static final void prettyPrintMbean(ObjectName mbean)
                                   throws JMException
Prints out all the attributes for the passed JMX MBean

Parameters:
mbean - The bean whose attributes will be pretty printed.
Throws:
JMException - on error with JMX operations


Copyright © 2012 Palantir Technologies. All Rights Reserved.