org.jboss.mx.util
Class MBeanServerLocator

java.lang.Object
  extended byorg.jboss.mx.util.MBeanServerLocator

public class MBeanServerLocator
extends java.lang.Object

A helper class to locate an MBeanServer. MBeanServer lookup strategy enhanced to allow the explicit setting of a particular instance to be returned. This is needed to allow re-using the jdk5 ManagementFactory.getPlatformMBeanServer() as our main MBeanServer. The DefaultDomain name of this server cannot be set, and it seems to be "null" by default (probably a bug).


Method Summary
static MBeanServer (src) locate()
          Returns the first available MBeanServer
static MBeanServer (src) locate(java.lang.String agentID)
          Returns the first MBeanServer registered under the agentID
static MBeanServer (src) locateJBoss()
          Returns the main jboss MBeanServer.
static void setJBoss(MBeanServer (src)  server)
          Optionally set the MBeanServer to be returned by calls to locateJBoss().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setJBoss

public static void setJBoss(MBeanServer (src)  server)
Optionally set the MBeanServer to be returned by calls to locateJBoss(). Setting this back to null reverts to the normal lookup strategy.

Parameters:
server - the main jboss MBeanServer or null

locate

public static MBeanServer (src)  locate(java.lang.String agentID)
Returns the first MBeanServer registered under the agentID

Parameters:
agentID - the id of the MBeanServer to look for
Returns:
the first MBeanServer with an agentID

locate

public static MBeanServer (src)  locate()
Returns the first available MBeanServer

Returns:
the first available MBeanServer

locateJBoss

public static MBeanServer (src)  locateJBoss()
Returns the main jboss MBeanServer. If there is one set using setJBoss(), it will be returned. Otherwise the strategy is to return the first MBeanServer registered under the "jboss" id (or else, default domain name)

Returns:
the main jboss MBeanServer
Throws:
java.lang.IllegalStateException - when no MBeanServer can be found