if (classLoading == null)
throw new IllegalStateException("The classLoading has not been set");
if (system == null)
throw new IllegalStateException("The system has not been set");
Module module = unit.getAttachment(Module.class);
if (module == null)
{
if (isTopLevelOnly())
throw new IllegalStateException("No module for top level deployment " + unit.getName());
else
return unit.getParent().getClassLoader();
}
if (module instanceof ClassLoaderPolicyModule == false)
throw new IllegalStateException("Module is not an instance of " + ClassLoaderPolicyModule.class.getName() + " actual=" + module.getClass().getName());
ClassLoaderPolicyModule classLoaderPolicyModule = (ClassLoaderPolicyModule) module;
boolean explicitTopLevel = false;
ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class);
if (clmd != null && clmd.isTopLevelClassLoader())
explicitTopLevel = true;
if (unit.isTopLevel() || module.getParentDomainName() != null || explicitTopLevel)
{
// Top level, just create the classloader
return classLoaderPolicyModule.registerClassLoaderPolicy(system);
}
else