- java.lang.Object
-
- javax.management.MBeanServerFactory
-
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 the
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 ofMBeanServerBuilder
, and must have a public empty constructor.By default, if no value for that property is specified, an instance of
javax.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
-
-
Method Summary
Methods Modifier and Type Method and 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 theMBeanServer
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.
-
-
-
Method Detail
-
releaseMBeanServer
public static void releaseMBeanServer(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
- ifmbeanServer
was not generated by one of thecreateMBeanServer
methods, or ifreleaseMBeanServer
was already called on it.SecurityException
- if there is a SecurityManager and the caller's permissions do not include or imply
.MBeanServerPermission
("releaseMBeanServer")
-
createMBeanServer
public static 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
- if there is a SecurityManager and the caller's permissions do not include or imply
.MBeanServerPermission
("createMBeanServer")JMRuntimeException
- if the propertyjavax.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 itsnewMBeanServerDelegate
ornewMBeanServer
methods.ClassCastException
- if the propertyjavax.management.builder.initial
exists and can be instantiated but is not assignment compatible withMBeanServerBuilder
.
-
createMBeanServer
public static MBeanServer createMBeanServer(String domain)
Return a new object implementing the
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 byMBeanServer.getDefaultDomain()
.- Returns:
- the newly created MBeanServer.
- Throws:
SecurityException
- if there is a SecurityManager and the caller's permissions do not include or imply
.MBeanServerPermission
("createMBeanServer")JMRuntimeException
- if the propertyjavax.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 itsnewMBeanServerDelegate
ornewMBeanServer
methods.ClassCastException
- if the propertyjavax.management.builder.initial
exists and can be instantiated but is not assignment compatible withMBeanServerBuilder
.
-
newMBeanServer
public 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. 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
- if there is a SecurityManager and the caller's permissions do not include or imply
.MBeanServerPermission
("newMBeanServer")JMRuntimeException
- if the propertyjavax.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 itsnewMBeanServerDelegate
ornewMBeanServer
methods.ClassCastException
- if the propertyjavax.management.builder.initial
exists and can be instantiated but is not assignment compatible withMBeanServerBuilder
.
-
newMBeanServer
public 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. 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 byMBeanServer.getDefaultDomain()
.- Returns:
- the newly created MBeanServer.
- Throws:
SecurityException
- if there is a SecurityManager and the caller's permissions do not include or imply
.MBeanServerPermission
("newMBeanServer")JMRuntimeException
- if the propertyjavax.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 itsnewMBeanServerDelegate
ornewMBeanServer
methods.ClassCastException
- if the propertyjavax.management.builder.initial
exists and can be instantiated but is not assignment compatible withMBeanServerBuilder
.
-
findMBeanServer
public static ArrayList<MBeanServer> findMBeanServer(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 withreleaseMBeanServer
.- 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 toagentId
are returned. The id of an MBeanServer is theMBeanServerId
attribute of its delegate MBean.- Returns:
- A list of MBeanServer objects.
- Throws:
SecurityException
- if there is a SecurityManager and the caller's permissions do not include or imply
.MBeanServerPermission
("findMBeanServer")
-
getClassLoaderRepository
public static ClassLoaderRepository getClassLoaderRepository(MBeanServer server)
Return the ClassLoaderRepository used by the given MBeanServer. This method is equivalent toserver.getClassLoaderRepository()
.- Parameters:
server
- The MBeanServer under examination. Since JMX 1.2, ifserver
isnull
, the result is aNullPointerException
. This behavior differs from what was implemented in JMX 1.1 - where the possibility to usenull
was deprecated.- Returns:
- The Class Loader Repository used by the given MBeanServer.
- Throws:
SecurityException
- if there is a SecurityManager and the caller's permissions do not include or imply
.MBeanPermission
("getClassLoaderRepository")NullPointerException
- ifserver
is null.
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/management/mbeanserverfactory.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.