* @param loader The ClassLoader.
* @param logicalName The ClassLoader MBean ObjectName.
*/
private void addClassLoader(ClassLoader loader,
final ObjectName logicalName) {
/**
* Called when the newly registered MBean is a ClassLoader
* If so, tell the ClassLoaderRepository (CLR) about it. We do
* this even if the loader is a PrivateClassLoader. In that
* case, the CLR remembers the loader for use when it is
* explicitly named (e.g. as the loader in createMBean) but
* does not add it to the list that is consulted by
* ClassLoaderRepository.loadClass.
*/
final ModifiableClassLoaderRepository clr =
instantiator.getClassLoaderRepository();
if (clr == null) {
final RuntimeException wrapped =
new IllegalArgumentException(
"Dynamic addition of class loaders" +
" is not supported");
throw new RuntimeOperationsException(wrapped,
"Exception occurred trying to register" +
" the MBean as a class loader");
}
clr.addClassLoader(logicalName, loader);
}