@Override
public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException,
MBeanRegistrationException, NotCompliantMBeanException {
Throwable error = null;
MBeanServerPlugin delegate = null;
final boolean readOnly = false;
try {
delegate = findDelegateForNewObject(name);
authorizeMBeanOperation(delegate, name, REGISTER_MBEAN, null, JmxAction.Impact.WRITE);
return checkNotAReservedDomainRegistrationIfObjectNameWasChanged(name, delegate.registerMBean(object, name), delegate);
} catch (Exception e) {
error = e;
if (e instanceof InstanceAlreadyExistsException) throw (InstanceAlreadyExistsException)e;
if (e instanceof MBeanRegistrationException) throw (MBeanRegistrationException)e;
if (e instanceof NotCompliantMBeanException) throw (NotCompliantMBeanException)e;
throw makeRuntimeException(e);
} finally {
if (shouldAuditLog(delegate, readOnly)) {
new MBeanServerAuditLogRecordFormatter(this, error, readOnly).registerMBean(object, name);
}
}
}