{
introspector.introspect(metadata);
if (!introspector.isMBeanCompliant(metadata)) throw new NotCompliantMBeanException("MBean is not compliant");
MBeanServerInterceptor head = getHeadInterceptor();
try
{
// With this call, the MBean implementor can replace the ObjectName with a subclass that is not secure, secure it again
head.registration(metadata, MBeanServerInterceptor.PRE_REGISTER);
metadata.name = secureObjectName(metadata.name);
metadata.instance = new ObjectInstance(metadata.name, metadata.info.getClassName());
register(metadata, privileged);
head.registration(metadata, MBeanServerInterceptor.POST_REGISTER_TRUE);
}
catch (Throwable x)
{
try
{
head.registration(metadata, MBeanServerInterceptor.POST_REGISTER_FALSE);
}
catch (MBeanRegistrationException ignored)
{/* Ignore this one to rethrow the other one */
}