}
}
private Domain initializeDomain(VFSClassLoaderScopingPolicy policy, VFSDeploymentUnit unit)
{
Module module = unit.getTopLevel().getAttachment(Module.class);
ClassLoader loader = unit.getClassLoader();
ClassLoader topLoader = unit.getTopLevel().getClassLoader();
VFSClassLoaderDomainRegistry registry = policy.getRegistry();
boolean isWar = unit.isAttachmentPresent("org.jboss.metadata.web.jboss.JBossWebMetaData");
if (isWar && loader != topLoader)
{
ScopedVFSClassLoaderDomain scopedDomain = (ScopedVFSClassLoaderDomain)registry.getRegisteredDomain(loader);
if (scopedDomain == null)
{
scopedDomain = (ScopedVFSClassLoaderDomain)registry.getRegisteredDomain(topLoader);
}
if (scopedDomain != null)
{
registry.initMapsForLoader(loader, module, scopedDomain);
}
policy.registerClassLoader(module, isWar, loader);
return scopedDomain;
}
else
{
ScopedVFSClassLoaderDomain scopedDomain = (ScopedVFSClassLoaderDomain)registry.getRegisteredDomain(loader);
if (scopedDomain == null)
{
if (!module.getDeterminedDomainName().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME))
{
ClassLoaderSystem system = ClassLoaderSystem.getInstance();
String domainName = module.getDeterminedDomainName();
ClassLoaderDomain domain = system.getDomain(domainName);
boolean parentDelegation = module.isJ2seClassLoadingCompliance();
String name = String.valueOf(System.identityHashCode(loader));
scopedDomain = new ScopedVFSClassLoaderDomain(loader, name, parentDelegation, AspectManager.getTopLevelAspectManager(), false, domain, registry);
}