Package org.jboss.classloading.spi.dependency

Examples of org.jboss.classloading.spi.dependency.Module


      }

      if (unit.isTopLevel() || unit.getParent().getClassLoader() != unit.getClassLoader())
      {
         //Only bother doing all this if we are a different loader from the parent unit
         Module module = getModuleRecursively(unit);
        
         if (module == null)
         {
            throw new IllegalStateException("No " + Module.class.getName() +
                  " attachment could be found in the following deployment unit or its parents: " + unit);
View Full Code Here


   {
      if (unit == null)
      {
         return null;
      }
      Module module = unit.getAttachment(Module.class);
      if (module == null)
      {
          return getModuleRecursively(unit.getParent());
      }
      return module;
View Full Code Here

      ScopedClassPool pool = null;
     
      if (cl instanceof RealClassLoader)
      {
         Module module = registry.getModule(cl);
         if (module != null && module.getDeterminedParentDomainName() != null)
         {
            //It is scoped
            ClassLoaderSystem sys = registry.getSystem();
            ClassLoaderDomain domain = sys.getDomain(module.getDeterminedDomainName());
            boolean parentFirst = module.isJ2seClassLoadingCompliance();
            ClassPool parentDomainPool = getParentUnitClassPool(cl);
            pool = new ScopedJBoss5ClassPool(cl, parent, parentDomainPool, repository, getTempURL(module), parentFirst, domain);
         }
         else
         {
View Full Code Here

         }
         classLoaderUnitParents.remove(loader);
         WeakReference<Module> moduleRef = classLoaderModules.remove(loader);
         if (moduleRef != null)
         {
            Module module = moduleRef.get();
            if (module != null)
            {
               moduleClassLoaders.remove(module);
            }
         }
View Full Code Here

         throw new IllegalStateException("The system has not been set");
   }

   public void deploy(DeploymentUnit unit, ClassLoadingTranslatorsMetaData deployment) throws DeploymentException
   {
      Module module = AttachmentLocator.searchAncestors(unit, Module.class);
      if (module == null || (module instanceof ClassLoaderPolicyModule == false))
         return;

      Map<Translator, TranslatorScope> added = new HashMap<Translator, TranslatorScope>();
      try
      {
         List<ClassLoadingTranslatorMetaData> translators = deployment.getTranslators();
         if (translators != null)
         {
            ClassLoaderPolicyModule clpm = (ClassLoaderPolicyModule) module;
            ClassLoaderDomain domain = system.getDomain(module.getDeterminedDomainName());
            ClassLoaderPolicy policy = clpm.getPolicy();
            ClassLoader cl = unit.getClassLoader();

            for (ClassLoadingTranslatorMetaData cltmd : translators)
            {
               TranslatorScope scope = cltmd.getScope();
               if (scope == null)
                  throw new IllegalArgumentException("Null scope for: " + cltmd);

               String className = cltmd.getClassName();
               Object instance = cl.loadClass(className).newInstance();
               String methodName = cltmd.getMethod();
               Translator translator;
               if (methodName != null)
                  translator = new ReflectionTranslator(instance, methodName);
               else
                  translator = Translator.class.cast(instance);

               scope.addTranslator(system, domain, policy, translator);
               added.put(translator, scope);
            }

            unit.addAttachment(TRANSLATORS_KEY, added);
         }
      }
      catch (Exception e)
      {
         ClassLoaderPolicyModule clpm = (ClassLoaderPolicyModule) module;
         ClassLoaderDomain domain = system.getDomain(module.getDeterminedDomainName());
         ClassLoaderPolicy policy = clpm.getPolicy();

         for (Map.Entry<Translator, TranslatorScope> entry : added.entrySet())
         {
            entry.getValue().removeTranslator(system, domain, policy, entry.getKey());
View Full Code Here

   @SuppressWarnings({"unchecked"})
   @Override
   public void undeploy(DeploymentUnit unit, ClassLoadingTranslatorsMetaData deployment)
   {
      Module module = AttachmentLocator.searchAncestors(unit, Module.class);
      if (module == null || (module instanceof ClassLoaderPolicyModule == false))
         return;

      Map<Translator, TranslatorScope> added = unit.getAttachment(TRANSLATORS_KEY, Map.class);
      if (added != null)
      {
         ClassLoaderPolicyModule clpm = (ClassLoaderPolicyModule) module;
         ClassLoaderDomain domain = system.getDomain(module.getDeterminedDomainName());
         ClassLoaderPolicy policy = clpm.getPolicy();

         for (Map.Entry<Translator, TranslatorScope> entry : added.entrySet())
         {
            entry.getValue().removeTranslator(system, domain, policy, entry.getKey());
View Full Code Here

      }
   }

   public void undeploy(DeploymentUnit unit, ClassLoadingMetaData deployment)
   {
      Module module = unit.removeAttachment(Module.class);
      if (module == null)
         return;
      classLoading.removeModule(module);
   }
View Full Code Here

      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;

      if (unit.isTopLevel() || module.getParentDomainName() != null)
      {
         // Top level, just create the classloader
         return classLoaderPolicyModule.registerClassLoaderPolicy(system);
      }
      else
View Full Code Here

   }

   @Override
   public void removeClassLoader(DeploymentUnit unit) throws Exception
   {
      Module module = unit.getAttachment(Module.class);
      if (module == null)
         return;

      ClassLoader classLoader = unit.getClassLoader();
      try
      {
         try
         {
            // Remove the classloader
            system.unregisterClassLoader(classLoader);
         }
         finally
         {
            // Try to tidy up empty domains
            String domainName = module.getDeterminedDomainName();
            if (ClassLoaderSystem.DEFAULT_DOMAIN_NAME.equals(domainName) == false)
            {
               ClassLoaderDomain domain = system.getDomain(domainName);
               if (domain.hasClassLoaders() == false)
                  system.unregisterDomain(domain);
            }
         }
      }
      finally
      {
         cleanup(unit, module);
         module.reset();
      }
  }
View Full Code Here

      }
   }

   public void undeploy(DeploymentUnit unit, ClassLoadingMetaData deployment)
   {
      Module module = unit.removeAttachment(Module.class);
      if (module == null)
         return;
      classLoading.removeModule(module);
   }
View Full Code Here

TOP

Related Classes of org.jboss.classloading.spi.dependency.Module

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.