CounterMonitor
, GaugeMonitor
, JMXConnectorServer
, MLet
, Monitor
, PrivateMLet
, RelationService
, RelationSupport
, RequiredModelMBean
, RMIConnectorServer
, StandardEmitterMBean
, StandardMBean
, StringMonitor
, Timer
public interface MBeanRegistration
Can be implemented by an MBean in order to carry out operations before and after being registered or unregistered from the MBean Server. An MBean can also implement this interface in order to get a reference to the MBean Server and/or its name within that MBean Server.
Modifier and Type | Method | Description |
---|---|---|
void |
postDeregister() |
Allows the MBean to perform any operations needed after having been unregistered in the MBean server. |
void |
postRegister |
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed. |
void |
preDeregister() |
Allows the MBean to perform any operations it needs before being unregistered by the MBean server. |
ObjectName |
preRegister |
Allows the MBean to perform any operations it needs before being registered in the MBean Server. |
ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
server
- The MBean Server in which the MBean will be registered.name
- The object name of the MBean. This name is null if the name parameter to one of the createMBean
or registerMBean
methods in the MBeanServer
interface is null. In that case, this method must return a non-null ObjectName for the new MBean.name
parameter is not null, it will usually but not necessarily be the returned value.Exception
- This exception will be caught by the MBean Server and re-thrown as an MBeanRegistrationException
.void postRegister(Boolean registrationDone)
If the implementation of this method throws a RuntimeException
or an Error
, the MBean Server will rethrow those inside a RuntimeMBeanException
or RuntimeErrorException
, respectively. However, throwing an exception in postRegister
will not change the state of the MBean: if the MBean was already registered (registrationDone
is true
), the MBean will remain registered.
This might be confusing for the code calling createMBean()
or registerMBean()
, as such code might assume that MBean registration has failed when such an exception is raised. Therefore it is recommended that implementations of postRegister
do not throw Runtime Exceptions or Errors if it can be avoided.
registrationDone
- Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.void preDeregister() throws Exception
Exception
- This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException
.void postDeregister()
If the implementation of this method throws a RuntimeException
or an Error
, the MBean Server will rethrow those inside a RuntimeMBeanException
or RuntimeErrorException
, respectively. However, throwing an exception in postDeregister
will not change the state of the MBean: the MBean was already successfully deregistered and will remain so.
This might be confusing for the code calling unregisterMBean()
, as it might assume that MBean deregistration has failed. Therefore it is recommended that implementations of postDeregister
do not throw Runtime Exceptions or Errors if it can be avoided.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.management/javax/management/MBeanRegistration.html