MBeanRegistration (Java SE 15 & JDK 15) (original) (raw)
All Known Implementing Classes:
[CounterMonitor](monitor/CounterMonitor.html "class in javax.management.monitor")
, [GaugeMonitor](monitor/GaugeMonitor.html "class in javax.management.monitor")
, [JMXConnectorServer](remote/JMXConnectorServer.html "class in javax.management.remote")
, [MLet](loading/MLet.html "class in javax.management.loading")
, [Monitor](monitor/Monitor.html "class in javax.management.monitor")
, [PrivateMLet](loading/PrivateMLet.html "class in javax.management.loading")
, [RelationService](relation/RelationService.html "class in javax.management.relation")
, [RelationSupport](relation/RelationSupport.html "class in javax.management.relation")
, [RequiredModelMBean](modelmbean/RequiredModelMBean.html "class in javax.management.modelmbean")
, [RMIConnectorServer](../../../java.management.rmi/javax/management/remote/rmi/RMIConnectorServer.html "class in javax.management.remote.rmi")
, [StandardEmitterMBean](StandardEmitterMBean.html "class in javax.management")
, [StandardMBean](StandardMBean.html "class in javax.management")
, [StringMonitor](monitor/StringMonitor.html "class in javax.management.monitor")
, [Timer](timer/Timer.html "class in javax.management.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.
Since:
1.5
Method Summary
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(Boolean registrationDone) | 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(MBeanServer server,ObjectName name) | Allows the MBean to perform any operations it needs before being registered in the MBean Server. |
Method Details
preRegister
Allows the MBean to perform any operations it needs before being registered in the MBean Server. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered in the MBean Server.
Parameters:
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 thecreateMBean
orregisterMBean
methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.
Returns:
The name under which the MBean is to be registered. This value must not be null. If thename
parameter is not null, it will usually but not necessarily be the returned value.
Throws:
[Exception](../../../java.base/java/lang/Exception.html "class in java.lang")
- This exception will be caught by the MBean Server and re-thrown as an MBeanRegistrationException.postRegister
void postRegister(Boolean registrationDone)
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.
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 inpostRegister
will not change the state of the MBean: if the MBean was already registered (registrationDone
istrue
), the MBean will remain registered.
This might be confusing for the code callingcreateMBean()
orregisterMBean()
, as such code might assume that MBean registration has failed when such an exception is raised. Therefore it is recommended that implementations ofpostRegister
do not throw Runtime Exceptions or Errors if it can be avoided.
Parameters:
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.preDeregister
void preDeregister() throws Exception
Allows the MBean to perform any operations it needs before being unregistered by the MBean server.
Throws:
[Exception](../../../java.base/java/lang/Exception.html "class in java.lang")
- This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.postDeregister
void postDeregister()
Allows the MBean to perform any operations needed after having been unregistered in the MBean server.
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 inpostDeregister
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 callingunregisterMBean()
, as it might assume that MBean deregistration has failed. Therefore it is recommended that implementations ofpostDeregister
do not throw Runtime Exceptions or Errors if it can be avoided.