Package org.jboss.classloader.spi

Examples of org.jboss.classloader.spi.ClassLoaderSystem


      assertClassEquality(testFactoryImplementationClass, instance.getClass());
   }
  
   public void testDelegateToAnotherCodeSource() throws Exception
   {
      ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap();

      MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B");
      pb.setPaths(ClassLoaderDomain.class);
      ClassLoader b = system.registerClassLoaderPolicy(pb);

      MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A");
      pa.setPaths(TestADelegateClassLoaderDomain.class);
      pa.setDelegates(Collections.singletonList(new FilteredDelegateLoader(pb)));
      ClassLoader a = system.registerClassLoaderPolicy(pa);
     
      Class<?> fromB = assertLoadClass(ClassLoaderDomain.class, b, false);
      Class<?> fromA = assertLoadClass(ClassLoaderDomain.class, a, b, false);
     
      Class<?> delegate = assertLoadClass(TestADelegateClassLoaderDomain.class, a, false);
View Full Code Here


      assertClassEquality(fromB, fromA);
   }
  
   public void testAbstractFactoryWrongWay() throws Exception
   {
      ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap();
     
      MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B");
      pb.setPaths(TestB1.class);

      MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A");
      pa.setPaths(TestA1.class);

      List<DelegateLoader> delegates = new ArrayList<DelegateLoader>();
      delegates.add(new FilteredDelegateLoader(pa));
      delegates.add(new FilteredDelegateLoader(pb));
      pa.setDelegates(delegates);
      pb.setDelegates(delegates);

      ClassLoader a = system.registerClassLoaderPolicy(pa);
      ClassLoader b = system.registerClassLoaderPolicy(pb);
     
      Class<?> testAbstractFactoryClass = assertLoadClass(TestAbstractFactory.class, b, a);
      Method method = testAbstractFactoryClass.getMethod("getInstance", (Class[]) null);
      Object instance = method.invoke(null, (Object[]) null);
      Class<?> testFactoryImplementationClass = assertLoadClass(TestFactoryImplementation.class, a, b);
View Full Code Here

      assertClassEquality(testFactoryImplementationClass, instance.getClass());
   }

   public void testLoadClassFromDefaultPackage() throws Exception
   {
      ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap();
      MockClassLoaderPolicy policy = createMockClassLoaderPolicy();
      policy.setPath("");
      policy.setPackageNames(new String[] { "" });
      ClassLoader classLoader = system.registerClassLoaderPolicy(policy);
     
      assertLoadClass("TestDefaultPackage", classLoader);
   }
View Full Code Here

      assertLoadClass("TestDefaultPackage", classLoader);
   }

   public void testLoadClassFromDefaultPackageFromDelegate() throws Exception
   {
      ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap();
      MockClassLoaderPolicy policy = createMockClassLoaderPolicy();
      policy.setPath("");
      policy.setPackageNames(new String[] { "" });
      MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy();
      policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy)));
      ClassLoader classLoader = system.registerClassLoaderPolicy(policy);
      ClassLoader classLoader2 = system.registerClassLoaderPolicy(policy2);
     
      assertLoadClass("TestDefaultPackage", classLoader2, classLoader);
   }
View Full Code Here

      assertLoadClass("TestDefaultPackage", classLoader2, classLoader);
   }

   public void testLoadClassFromDefaultPackageFromExports() throws Exception
   {
      ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap();
      MockClassLoaderPolicy policy = createMockClassLoaderPolicy();
      policy.setPath("");
      policy.setPackageNames(new String[] { "" });
      MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy();
      policy2.setImportAll(true);
      ClassLoader classLoader = system.registerClassLoaderPolicy(policy);
      ClassLoader classLoader2 = system.registerClassLoaderPolicy(policy2);
     
      assertLoadClass("TestDefaultPackage", classLoader2, classLoader);
   }
View Full Code Here

      assertLoadClass("TestDefaultPackage", classLoader2, classLoader);
   }

   public void testLoadClassFromDefaultPackageFromParent() throws Exception
   {
      ClassLoaderSystem system = createClassLoaderSystem();
      ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY);
      MockClassLoaderPolicy policy = createMockClassLoaderPolicy();
      policy.setPath("");
      policy.setPackageNames(new String[] { "" });
      ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parent);
      MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy();
      ClassLoader classLoader = system.registerClassLoaderPolicy(parent, policy);
      ClassLoader classLoader2 = system.registerClassLoaderPolicy(child, policy2);
     
      assertLoadClass("TestDefaultPackage", classLoader2, classLoader);
   }
View Full Code Here

   public void testAbstractFactoryConcurrent() throws Exception
   {
      for (int i = 0; i < 10; ++i)
      {
         getLog().debug("Attempt: " + i);
         ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap();
        
         MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B");
         pb.setPaths(TestB1.class);

         MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A");
         pa.setPaths(TestA1.class);

         List<DelegateLoader> delegates = new ArrayList<DelegateLoader>();
         delegates.add(new FilteredDelegateLoader(pa));
         delegates.add(new FilteredDelegateLoader(pb));
         pa.setDelegates(delegates);
         pb.setDelegates(delegates);

         final ClassLoader a = system.registerClassLoaderPolicy(pa);
         final ClassLoader b = system.registerClassLoaderPolicy(pb);
        
         Class<?> testSleep = assertLoadClass(TestSleep.class, a);
         Field field = testSleep.getField("sleep");
         field.set(null, new Long(1));
        
View Full Code Here

      super(name);
   }
  
   public void testGetInstance() throws Exception
   {
      ClassLoaderSystem instance = ClassLoaderSystem.getInstance();
      assertNotNull(instance);
     
      ClassLoaderSystem instance2 = ClassLoaderSystem.getInstance();
      assertTrue("Should be the same instance", instance == instance2);
   }
View Full Code Here

      return MockClassLoaderHelper.createMockClassLoaderSystem();
   }
  
   protected ClassLoaderSystem createClassLoaderSystemWithModifiedBootstrap()
   {
      ClassLoaderSystem result = createClassLoaderSystem();
      result.getDefaultDomain().setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY);
      return result;
   }
View Full Code Here

      return result;
   }
  
   protected ClassLoader createClassLoaderSystemWithModifiedBootstrapAndMockClassLoader()
   {
      ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap();
      return createAndRegisterMockClassLoader(system);
   }
View Full Code Here

TOP

Related Classes of org.jboss.classloader.spi.ClassLoaderSystem

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.