use of org.apache.felix.mosgi.jmx.agent.mx4j.ImplementationException in project felix by apache.
the class MX4JMBeanServer method registerImpl.
private void registerImpl(MBeanMetaData metadata, boolean privileged) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
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 */
}
if (x instanceof SecurityException) {
throw (SecurityException) x;
} else if (x instanceof InstanceAlreadyExistsException) {
throw (InstanceAlreadyExistsException) x;
} else if (x instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException) x;
} else if (x instanceof RuntimeOperationsException) {
throw (RuntimeOperationsException) x;
} else if (x instanceof JMRuntimeException) {
throw (JMRuntimeException) x;
} else if (x instanceof Exception) {
throw new MBeanRegistrationException((Exception) x);
} else if (x instanceof Error) {
throw new MBeanRegistrationException(new RuntimeErrorException((Error) x));
} else {
throw new ImplementationException();
}
}
if (metadata.mbean instanceof ClassLoader && !(metadata.mbean instanceof PrivateClassLoader)) {
ClassLoader cl = (ClassLoader) metadata.mbean;
getModifiableClassLoaderRepository().addClassLoader(cl);
}
}
use of org.apache.felix.mosgi.jmx.agent.mx4j.ImplementationException in project felix by apache.
the class InvokerMBeanServerInterceptor method registration.
public void registration(MBeanMetaData metadata, int operation) throws MBeanRegistrationException {
if (!(metadata.mbean instanceof MBeanRegistration))
return;
MBeanRegistration registrable = (MBeanRegistration) metadata.mbean;
try {
switch(operation) {
case PRE_REGISTER:
ObjectName objName = registrable.preRegister(outerServer, metadata.name);
metadata.name = objName;
break;
case POST_REGISTER_TRUE:
registrable.postRegister(Boolean.TRUE);
break;
case POST_REGISTER_FALSE:
registrable.postRegister(Boolean.FALSE);
break;
case PRE_DEREGISTER:
registrable.preDeregister();
break;
case POST_DEREGISTER:
registrable.postDeregister();
break;
default:
throw new ImplementationException();
}
} catch (RuntimeException x) {
throw new RuntimeMBeanException(x);
} catch (Exception x) {
if (x instanceof MBeanRegistrationException) {
throw (MBeanRegistrationException) x;
}
throw new MBeanRegistrationException(x);
}
}
Aggregations