Module
JMX- Implement MBeanRegistration interface Action - Generated Code
Authors: Alexandre Neubert, Thomas Leveque, Jean-Francois Denise
Implement
MBeanRegistration interface Action
The code is generated at the end of the target MBean class.
/**
* 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.
* @param server The MBean server in which the
MBean will be registered.
* @name 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.
* @return The name under which the MBean is to
be registered. This value
* must not be null. If the name parameter is
not null, it will usually
* but not necessarily be the returned value.
* @trow Exception This exception will be
caught by the MBean server and
* re-thrown as an MBeanRegistrationException.
*/
public ObjectName preRegister(MBeanServer server,
ObjectName name) throws Exception {
return name;
}
/**
* Allows the MBean to perform any operations
needed after having
* been registered in the MBean server or after
the registration has
* failed.
* @param registrationDone Indicates wether or
not the MBean has been
* successfully registered in the MBean server.
The value false means
* that the registration has failed.
*/
public void postRegister(Boolean registrationDone) {
//TODO postRegister
implementation;
}
/**
* Allows the MBean to perform any operations
it needs before being
* unregistered by the MBean server.
* @trow Exception This exception will be
caught by the MBean server and
* re-thrown as an MBeanRegistrationException.
*/
public void preDeregister() throws Exception {
//TODO preDeregister
implementation;
}
/**
* Allows the MBean to perform any operations
needed after having been
* unregistered in the MBean server.
*/
public void postDeregister() {
//TODO postDeregister
implementation;
}
The following is only generated if user has choosed to keep the
references of the preRegister method parameters.
private MBeanServer mbeanServer;
private ObjectName objectName;
In this case, the preRegister method body is :
public ObjectName preRegister(MBeanServer
server, ObjectName name) throws Exception {
objectName =
name;
mbeanServer = server;
return name;
}