log.debug(this + " registerClassLoader " + classLoader.toString());
if (getClassLoaderSystem() == null)
throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString());
ClassLoaderPolicy policy = classLoader.getPolicy();
BaseDelegateLoader exported = policy.getExported();
if (exported != null && exported.getPolicy() == null)
throw new IllegalStateException("The exported delegate " + exported + " is too lazy for " + policy.toLongString());
try
{
beforeRegisterClassLoader(classLoader, policy);
}
catch (Throwable t)
{
log.warn("Error in beforeRegisterClassLoader: " + this + " classLoader=" + classLoader.toLongString(), t);
}
BaseClassLoaderPolicy basePolicy = classLoader.getPolicy();
basePolicy.setClassLoaderDomain(this);
// FINDBUGS: This synchronization is correct - more than addIfNotPresent behaviour
synchronized (classLoaders)
{
// Create the information
ClassLoaderInformation info = new ClassLoaderInformation(classLoader, policy, order++);
classLoaders.add(info);
basePolicy.setInformation(info);
// Index the packages
String[] packageNames = policy.getPackageNames();
if (packageNames != null && info.getExported() != null)
{
for (String packageName : packageNames)
{
List<ClassLoaderInformation> list = classLoadersByPackageName.get(packageName);