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.
The default implementation of this method returns the name
parameter. It does nothing else for
Standard MBeans. For MXBeans, it records the MBeanServer
and ObjectName
parameters so they can be used to translate
inter-MXBean references.
It is good practice for a subclass that overrides this method
to call the overridden method via super.preRegister(...)
.
This is necessary if this object is an MXBean that is referenced
by attributes or operations in other MXBeans.
Returns:
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.
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 the
createMBean
or
registerMBean
methods in the {@link MBeanServer}
interface is null. In that case, this method must return a
non-null ObjectName for the new MBean.
Throws:
-
IllegalArgumentException - if this is an MXBean and
{@code name} is null.
-
InstanceAlreadyExistsException - if this is an MXBean and
it has already been registered under another name (in this
MBean Server or another).
-
Exception - no other checked exceptions are thrown by
this method but {@code Exception} is declared so that subclasses
can override the method and throw their own exceptions.
Since:
1.6