javax.management
Class MBeanServerFactory

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.management.MBeanServerFactory

public class MBeanServerFactory
extends Object sample code for java.lang.Object definition code for java.lang.Object

Provides MBean server references. There are no instances of this class.

Since JMX 1.2 this class makes it possible to replace the default MBeanServer implementation. This is done using the MBeanServerBuilder sample code for javax.management.MBeanServerBuilder definition code for javax.management.MBeanServerBuilder class. The class of the initial MBeanServerBuilder to be instantiated can be specified through the javax.management.builder.initial system property. The specified class must be a public subclass of MBeanServerBuilder sample code for javax.management.MBeanServerBuilder definition code for javax.management.MBeanServerBuilder , and must have a public empty constructor.

By default, if no value for that property is specified, an instance of javax.management.MBeanServerBuilder sample code for javax.management.MBeanServerBuilder definition code for javax.management.MBeanServerBuilder is created. Otherwise, the MBeanServerFactory attempts to load the specified class using Thread.currentThread().getContextClassLoader() sample code for java.lang.Thread.getContextClassLoader() definition code for java.lang.Thread.getContextClassLoader() , or if that is null, Class.forName() sample code for java.lang.Class.forName(java.lang.String) definition code for java.lang.Class.forName(java.lang.String) . Then it creates an initial instance of that Class using Class.newInstance() sample code for java.lang.Class.newInstance() definition code for java.lang.Class.newInstance() . If any checked exception is raised during this process (e.g. ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException , InstantiationException sample code for java.lang.InstantiationException definition code for java.lang.InstantiationException ) the MBeanServerFactory will propagate this exception from within a RuntimeException.

The javax.management.builder.initial system property is consulted every time a new MBeanServer needs to be created, and the class pointed to by that property is loaded. If that class is different from that of the current MBeanServerBuilder, then a new MBeanServerBuilder is created. Otherwise, the MBeanServerFactory may create a new MBeanServerBuilder or reuse the current one.

If the class pointed to by the property cannot be loaded, or does not correspond to a valid subclass of MBeanServerBuilder then an exception is propagated, and no MBeanServer can be created until the javax.management.builder.initial system property is reset to valid value.

The MBeanServerBuilder makes it possible to wrap the MBeanServers returned by the default MBeanServerBuilder implementation, for the purpose of e.g. adding an additional security layer.

Since:
1.5

Method Summary
static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer createMBeanServer sample code for javax.management.MBeanServerFactory.createMBeanServer() definition code for javax.management.MBeanServerFactory.createMBeanServer() ()
          Return a new object implementing the MBeanServer interface with a standard default domain name.
static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer createMBeanServer sample code for javax.management.MBeanServerFactory.createMBeanServer(java.lang.String) definition code for javax.management.MBeanServerFactory.createMBeanServer(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  domain)
          Return a new object implementing the MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer interface with the specified default domain name.
static ArrayList sample code for java.util.ArrayList definition code for java.util.ArrayList findMBeanServer sample code for javax.management.MBeanServerFactory.findMBeanServer(java.lang.String) definition code for javax.management.MBeanServerFactory.findMBeanServer(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  agentId)
          Return a list of registered MBeanServer objects.
static ClassLoaderRepository sample code for javax.management.loading.ClassLoaderRepository definition code for javax.management.loading.ClassLoaderRepository getClassLoaderRepository sample code for javax.management.MBeanServerFactory.getClassLoaderRepository(javax.management.MBeanServer) definition code for javax.management.MBeanServerFactory.getClassLoaderRepository(javax.management.MBeanServer) (MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  server)
          Return the ClassLoaderRepository used by the given MBeanServer.
static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer newMBeanServer sample code for javax.management.MBeanServerFactory.newMBeanServer() definition code for javax.management.MBeanServerFactory.newMBeanServer() ()
          Return a new object implementing the MBeanServer interface with a standard default domain name, without keeping an internal reference to this new object.
static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer newMBeanServer sample code for javax.management.MBeanServerFactory.newMBeanServer(java.lang.String) definition code for javax.management.MBeanServerFactory.newMBeanServer(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  domain)
          Return a new object implementing the MBeanServer interface with the specified default domain name, without keeping an internal reference to this new object.
static void releaseMBeanServer sample code for javax.management.MBeanServerFactory.releaseMBeanServer(javax.management.MBeanServer) definition code for javax.management.MBeanServerFactory.releaseMBeanServer(javax.management.MBeanServer) (MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  mbeanServer)
          Remove internal MBeanServerFactory references to a created MBeanServer.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Method Detail

releaseMBeanServer sample code for javax.management.MBeanServerFactory.releaseMBeanServer(javax.management.MBeanServer) definition code for javax.management.MBeanServerFactory.releaseMBeanServer(javax.management.MBeanServer)

public static void releaseMBeanServer(MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  mbeanServer)
Remove internal MBeanServerFactory references to a created MBeanServer. This allows the garbage collector to remove the MBeanServer object.

Parameters:
mbeanServer - the MBeanServer object to remove.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if mbeanServer was not generated by one of the createMBeanServer methods, or if releaseMBeanServer was already called on it.
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if there is a SecurityManager and the caller's permissions do not include or imply MBeanServerPermission sample code for javax.management.MBeanServerPermission definition code for javax.management.MBeanServerPermission ("releaseMBeanServer").

createMBeanServer sample code for javax.management.MBeanServerFactory.createMBeanServer() definition code for javax.management.MBeanServerFactory.createMBeanServer()

public static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  createMBeanServer()

Return a new object implementing the MBeanServer interface with a standard default domain name. The default domain name is used as the domain part in the ObjectName of MBeans when the domain is specified by the user is null.

The standard default domain name is DefaultDomain.

The MBeanServer reference is internally kept. This will allow findMBeanServer to return a reference to this MBeanServer object.

This method is equivalent to createMBeanServer(null).

Returns:
the newly created MBeanServer.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if there is a SecurityManager and the caller's permissions do not include or imply MBeanServerPermission sample code for javax.management.MBeanServerPermission definition code for javax.management.MBeanServerPermission ("createMBeanServer").
JMRuntimeException sample code for javax.management.JMRuntimeException definition code for javax.management.JMRuntimeException - if the property javax.management.builder.initial exists but the class it names cannot be instantiated through a public no-argument constructor; or if the instantiated builder returns null from its newMBeanServerDelegate sample code for javax.management.MBeanServerBuilder.newMBeanServerDelegate() definition code for javax.management.MBeanServerBuilder.newMBeanServerDelegate() or newMBeanServer sample code for javax.management.MBeanServerBuilder.newMBeanServer(java.lang.String, javax.management.MBeanServer, javax.management.MBeanServerDelegate) definition code for javax.management.MBeanServerBuilder.newMBeanServer(java.lang.String, javax.management.MBeanServer, javax.management.MBeanServerDelegate) methods.
ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException - if the property javax.management.builder.initial exists and can be instantiated but is not assignment compatible with MBeanServerBuilder sample code for javax.management.MBeanServerBuilder definition code for javax.management.MBeanServerBuilder .

createMBeanServer sample code for javax.management.MBeanServerFactory.createMBeanServer(java.lang.String) definition code for javax.management.MBeanServerFactory.createMBeanServer(java.lang.String)

public static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  createMBeanServer(String sample code for java.lang.String definition code for java.lang.String  domain)

Return a new object implementing the MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer interface with the specified default domain name. The given domain name is used as the domain part in the ObjectName of MBeans when the domain is specified by the user is null.

The MBeanServer reference is internally kept. This will allow findMBeanServer to return a reference to this MBeanServer object.

Parameters:
domain - the default domain name for the created MBeanServer. This is the value that will be returned by MBeanServer.getDefaultDomain() sample code for javax.management.MBeanServer.getDefaultDomain() definition code for javax.management.MBeanServer.getDefaultDomain() .
Returns:
the newly created MBeanServer.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if there is a SecurityManager and the caller's permissions do not include or imply MBeanServerPermission sample code for javax.management.MBeanServerPermission definition code for javax.management.MBeanServerPermission ("createMBeanServer").
JMRuntimeException sample code for javax.management.JMRuntimeException definition code for javax.management.JMRuntimeException - if the property javax.management.builder.initial exists but the class it names cannot be instantiated through a public no-argument constructor; or if the instantiated builder returns null from its newMBeanServerDelegate sample code for javax.management.MBeanServerBuilder.newMBeanServerDelegate() definition code for javax.management.MBeanServerBuilder.newMBeanServerDelegate() or newMBeanServer sample code for javax.management.MBeanServerBuilder.newMBeanServer(java.lang.String, javax.management.MBeanServer, javax.management.MBeanServerDelegate) definition code for javax.management.MBeanServerBuilder.newMBeanServer(java.lang.String, javax.management.MBeanServer, javax.management.MBeanServerDelegate) methods.
ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException - if the property javax.management.builder.initial exists and can be instantiated but is not assignment compatible with MBeanServerBuilder sample code for javax.management.MBeanServerBuilder definition code for javax.management.MBeanServerBuilder .

newMBeanServer sample code for javax.management.MBeanServerFactory.newMBeanServer() definition code for javax.management.MBeanServerFactory.newMBeanServer()

public static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  newMBeanServer()

Return a new object implementing the MBeanServer interface with a standard default domain name, without keeping an internal reference to this new object. The default domain name is used as the domain part in the ObjectName of MBeans when the domain is specified by the user is null.

The standard default domain name is DefaultDomain.

No reference is kept. findMBeanServer will not be able to return a reference to this MBeanServer object, but the garbage collector will be able to remove the MBeanServer object when it is no longer referenced.

This method is equivalent to newMBeanServer(null).

Returns:
the newly created MBeanServer.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if there is a SecurityManager and the caller's permissions do not include or imply MBeanServerPermission sample code for javax.management.MBeanServerPermission definition code for javax.management.MBeanServerPermission ("newMBeanServer").
JMRuntimeException sample code for javax.management.JMRuntimeException definition code for javax.management.JMRuntimeException - if the property javax.management.builder.initial exists but the class it names cannot be instantiated through a public no-argument constructor; or if the instantiated builder returns null from its newMBeanServerDelegate sample code for javax.management.MBeanServerBuilder.newMBeanServerDelegate() definition code for javax.management.MBeanServerBuilder.newMBeanServerDelegate() or newMBeanServer sample code for javax.management.MBeanServerBuilder.newMBeanServer(java.lang.String, javax.management.MBeanServer, javax.management.MBeanServerDelegate) definition code for javax.management.MBeanServerBuilder.newMBeanServer(java.lang.String, javax.management.MBeanServer, javax.management.MBeanServerDelegate) methods.
ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException - if the property javax.management.builder.initial exists and can be instantiated but is not assignment compatible with MBeanServerBuilder sample code for javax.management.MBeanServerBuilder definition code for javax.management.MBeanServerBuilder .

newMBeanServer sample code for javax.management.MBeanServerFactory.newMBeanServer(java.lang.String) definition code for javax.management.MBeanServerFactory.newMBeanServer(java.lang.String)

public static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  newMBeanServer(String sample code for java.lang.String definition code for java.lang.String  domain)

Return a new object implementing the MBeanServer interface with the specified default domain name, without keeping an internal reference to this new object. The given domain name is used as the domain part in the ObjectName of MBeans when the domain is specified by the user is null.

No reference is kept. findMBeanServer will not be able to return a reference to this MBeanServer object, but the garbage collector will be able to remove the MBeanServer object when it is no longer referenced.

Parameters:
domain - the default domain name for the created MBeanServer. This is the value that will be returned by MBeanServer.getDefaultDomain() sample code for javax.management.MBeanServer.getDefaultDomain() definition code for javax.management.MBeanServer.getDefaultDomain() .
Returns:
the newly created MBeanServer.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if there is a SecurityManager and the caller's permissions do not include or imply MBeanServerPermission sample code for javax.management.MBeanServerPermission definition code for javax.management.MBeanServerPermission ("newMBeanServer").
JMRuntimeException sample code for javax.management.JMRuntimeException definition code for javax.management.JMRuntimeException - if the property javax.management.builder.initial exists but the class it names cannot be instantiated through a public no-argument constructor; or if the instantiated builder returns null from its newMBeanServerDelegate sample code for javax.management.MBeanServerBuilder.newMBeanServerDelegate() definition code for javax.management.MBeanServerBuilder.newMBeanServerDelegate() or newMBeanServer sample code for javax.management.MBeanServerBuilder.newMBeanServer(java.lang.String, javax.management.MBeanServer, javax.management.MBeanServerDelegate) definition code for javax.management.MBeanServerBuilder.newMBeanServer(java.lang.String, javax.management.MBeanServer, javax.management.MBeanServerDelegate) methods.
ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException - if the property javax.management.builder.initial exists and can be instantiated but is not assignment compatible with MBeanServerBuilder sample code for javax.management.MBeanServerBuilder definition code for javax.management.MBeanServerBuilder .

findMBeanServer sample code for javax.management.MBeanServerFactory.findMBeanServer(java.lang.String) definition code for javax.management.MBeanServerFactory.findMBeanServer(java.lang.String)

public static ArrayList sample code for java.util.ArrayList definition code for java.util.ArrayList  findMBeanServer(String sample code for java.lang.String definition code for java.lang.String  agentId)

Return a list of registered MBeanServer objects. A registered MBeanServer object is one that was created by one of the createMBeanServer methods and not subsequently released with releaseMBeanServer.

Parameters:
agentId - The agent identifier of the MBeanServer to retrieve. If this parameter is null, all registered MBeanServers in this JVM are returned. Otherwise, only MBeanServers whose id is equal to agentId are returned. The id of an MBeanServer is the MBeanServerId attribute of its delegate MBean.
Returns:
A list of MBeanServer objects.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if there is a SecurityManager and the caller's permissions do not include or imply MBeanServerPermission sample code for javax.management.MBeanServerPermission definition code for javax.management.MBeanServerPermission ("findMBeanServer").

getClassLoaderRepository sample code for javax.management.MBeanServerFactory.getClassLoaderRepository(javax.management.MBeanServer) definition code for javax.management.MBeanServerFactory.getClassLoaderRepository(javax.management.MBeanServer)

public static ClassLoaderRepository sample code for javax.management.loading.ClassLoaderRepository definition code for javax.management.loading.ClassLoaderRepository  getClassLoaderRepository(MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  server)
Return the ClassLoaderRepository used by the given MBeanServer. This method is equivalent to server.getClassLoaderRepository() sample code for javax.management.MBeanServer.getClassLoaderRepository() definition code for javax.management.MBeanServer.getClassLoaderRepository() .

Parameters:
server - The MBeanServer under examination. Since JMX 1.2, if server is null, the result is a NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException . This behavior differs from what was implemented in JMX 1.1 - where the possibility to use null was deprecated.
Returns:
The Class Loader Repository used by the given MBeanServer.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if there is a SecurityManager and the caller's permissions do not include or imply MBeanPermission sample code for javax.management.MBeanPermission definition code for javax.management.MBeanPermission ("getClassLoaderRepository").
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if server is null.