MBeanServerFactory (Java SE 15 & JDK 15) (original) (raw)


public class MBeanServerFactory extends 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 theMBeanServerBuilder class. The class of the initial MBeanServerBuilder to be instantiated can be specified through thejavax.management.builder.initial system property. The specified class must be a public subclass ofMBeanServerBuilder, and must have a public empty constructor.

By default, if no value for that property is specified, an instance ofjavax.management.MBeanServerBuilder is created. Otherwise, the MBeanServerFactory attempts to load the specified class usingThread.currentThread().getContextClassLoader(), or if that is null,Class.forName(). Then it creates an initial instance of that Class usingClass.newInstance(). If any checked exception is raised during this process (e.g.ClassNotFoundException,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

Modifier and Type Method Description
static MBeanServer createMBeanServer() Return a new object implementing the MBeanServer interface with a standard default domain name.
static MBeanServer createMBeanServer​(String domain) Return a new object implementing the MBeanServer interface with the specified default domain name.
static ArrayList<MBeanServer> findMBeanServer​(String agentId) Return a list of registered MBeanServer objects.
static ClassLoaderRepository getClassLoaderRepository​(MBeanServer server) Return the ClassLoaderRepository used by the given MBeanServer.
static 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.
static MBeanServer newMBeanServer​(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​(MBeanServer mbeanServer) Remove internal MBeanServerFactory references to a created MBeanServer.

Methods declared in class java.lang.Object

[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)