[jboss-cvs] JBossAS SVN: r106974 - in projects/cl-benchmark/trunk: src/test/java/org/jboss/test/cl/benchmark and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 21 07:29:38 EDT 2010


Author: kabir.khan at jboss.com
Date: 2010-07-21 07:29:38 -0400 (Wed, 21 Jul 2010)
New Revision: 106974

Added:
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmarkTestDelegate.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepClassLoaderBenchmarkTestDelegate.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/AbstractThreeDeepClassLoaderBenchmark.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportExportAllOwnLoaderBenchmarkTestCase.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportModuleLoaderBenchmarkTestCase.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportPackageLoaderBenchmarkTestCase.java
Removed:
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderBenchmarkTestDelegate.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOtherAlreadyLoadedBenchmarkTestCase.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOtherNotAlreadyLoadedBenchmarkTestCase.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java
Modified:
   projects/cl-benchmark/trunk/pom.xml
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java
   projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java
Log:
Set up exact classloading and generate classes instead of using as classes for more control over what gets loaded

Modified: projects/cl-benchmark/trunk/pom.xml
===================================================================
--- projects/cl-benchmark/trunk/pom.xml	2010-07-21 06:30:38 UTC (rev 106973)
+++ projects/cl-benchmark/trunk/pom.xml	2010-07-21 11:29:38 UTC (rev 106974)
@@ -18,38 +18,39 @@
   </scm>
 
   <properties>
-    <version.jboss.jbossas>6.0.0.20100429-M3</version.jboss.jbossas>
+    <version.org.jboss.shrinkwrap>1.0.0-alpha-9</version.org.jboss.shrinkwrap>
+    <version.javassist>3.12.1.GA</version.javassist>
+    <version.org.jboss.cl>2.2.0.Alpha7</version.org.jboss.cl>    
     <version.org.jboss.test>1.1.5.GA</version.org.jboss.test>
     <version.junit>4.4</version.junit>
   </properties>
 
   <dependencies>
     <dependency>
-      <groupId>org.jboss.jbossas</groupId>
-      <artifactId>jboss-as-depchain</artifactId>
-      <version>${version.jboss.jbossas}</version>
-      <type>pom</type>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-dependency</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-kernel</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-aop-mc-int</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.jboss.microcontainer</groupId>
-          <artifactId>jboss-jmx-mc-int</artifactId>
-        </exclusion>
-      </exclusions>
+      <groupId>javassist</groupId>
+      <artifactId>javassist</artifactId>
+      <version>${version.javassist}</version>
+      <scope>test</scope>
     </dependency>
-  
     <dependency>
+      <groupId>org.jboss.shrinkwrap</groupId>
+      <artifactId>shrinkwrap-api</artifactId>
+      <version>${version.org.jboss.shrinkwrap}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.shrinkwrap</groupId>
+      <artifactId>shrinkwrap-impl-base</artifactId>
+      <version>${version.org.jboss.shrinkwrap}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.cl</groupId>
+      <artifactId>jboss-classloading-vfs</artifactId>
+      <version>${version.org.jboss.cl}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.jboss.test</groupId>
       <artifactId>jboss-test</artifactId>
       <version>${version.org.jboss.test}</version>
@@ -61,19 +62,12 @@
         </exclusion>
       </exclusions>      
     </dependency>
-
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>${version.junit}</version>
       <scope>test</scope>
     </dependency>
-    
-    <!-- dependency>
-      <groupId></groupId>
-      <artifactId></artifactId>
-      <version>${}</version>
-    </dependency -->
   </dependencies>
 
 </project>
\ No newline at end of file

Modified: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java	2010-07-21 06:30:38 UTC (rev 106973)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -21,6 +21,7 @@
 */
 package org.jboss.test.cl.benchmark;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
@@ -28,8 +29,8 @@
 import org.jboss.classloader.spi.ClassLoaderDomain;
 import org.jboss.classloader.spi.ClassLoaderSystem;
 import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
 import org.jboss.test.AbstractTestCaseWithSetup;
-import org.jboss.test.AbstractTestDelegate;
 
 /**
  * 
@@ -38,23 +39,16 @@
  */
 public abstract class AbstractClassLoaderBenchmark extends AbstractTestCaseWithSetup
 {
-   protected static final int NUM_CLASSES_TO_LOAD = 5;
-   
    public AbstractClassLoaderBenchmark(String name)
    {
       super(name);
    }
 
-   public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+   protected AbstractClassLoaderBenchmarkTestDelegate getBenchmarkTestDelegate()
    {
-      return new ClassLoaderBenchmarkTestDelegate(clazz);
+      return (AbstractClassLoaderBenchmarkTestDelegate)getDelegate();
    }
    
-   protected ClassLoaderBenchmarkTestDelegate getBenchmarkTestDelegate()
-   {
-      return (ClassLoaderBenchmarkTestDelegate)getDelegate();
-   }
-   
    public static ClassLoaderSystem getClassLoaderSystem()
    {
       DefaultClassLoaderSystem system = new DefaultClassLoaderSystem();
@@ -63,39 +57,58 @@
       return system;
    }
 
-   private void trim(List<ClassLoaderInfo> infos)
+   private void trimLoadersWithNoClasses(List<ClassLoaderInfo> infos)
    {
       for (Iterator<ClassLoaderInfo> it = infos.iterator() ; it.hasNext() ; )
       {
-         if (it.next().getClassNames().size() == 0)
+         String[] classes = it.next().getClassesToLoad();
+         if (classes == null || classes.length == 0)
             it.remove();
       }
    }
    
+   private List<ClassLoaderInfo> getLoadersForLoading(List<ClassLoaderInfo> infos)
+   {
+      int classes = 0;
+      List<ClassLoaderInfo> result = new ArrayList<ClassLoaderInfo>();
+      for (Iterator<ClassLoaderInfo> it = infos.iterator() ; it.hasNext() ; )
+      {
+         ClassLoaderInfo current = it.next();
+         if (current.isLoadClasses())
+         {
+            result.add(current);
+            classes += current.getClassesToLoad().length;
+         }
+      }
+      System.out.println("Will load a total of " + classes + " classes from " + result.size() + " loaders.");
+      return result;
+   }
+   
    protected void runBenchmark(BenchmarkScenario scenario) throws Exception
    {
       List<ClassLoaderInfo> classLoaderInfos = scenario.createFactories(getBenchmarkTestDelegate().getClassPathElements());
       
-      System.out.println("Starting run. " + classLoaderInfos.size() + " jars indexed, will attempt to load " + NUM_CLASSES_TO_LOAD + " class from each.");
-      trim (classLoaderInfos);
+      System.out.println("Starting run. " + classLoaderInfos.size() + " jars indexed");
+      trimLoadersWithNoClasses(classLoaderInfos);
       System.out.println("Trimmed the empty jars, " + classLoaderInfos.size() + " to deploy.");
       
       LoadingResult result = new LoadingResult();
       
       long start = System.currentTimeMillis();
       for (ClassLoaderInfo info : classLoaderInfos) {
-         info.initialize(result, getBenchmarkTestDelegate().install(info.getFactory()), NUM_CLASSES_TO_LOAD);
+         info.initialize(result, getBenchmarkTestDelegate().install(info.getFactory()));
       }
       long time = System.currentTimeMillis() - start;
       System.out.println("Creating " + classLoaderInfos.size() + " class loaders took." + time + "ms");
       
+      List<ClassLoaderInfo> infosToLoad = getLoadersForLoading(classLoaderInfos);
+      
       System.out.println("Load classes...");
       
       start = System.currentTimeMillis();
-      for (ClassLoaderInfo info : classLoaderInfos)
+      for (ClassLoaderInfo info : infosToLoad)
       {
-         loadClasses(info, info.getOwnClassesToLoad());
-         loadClasses(info, info.getOtherClassesToLoad());
+         loadClasses(info, info.getClassesToLoad());
       }
 
       time = System.currentTimeMillis() - start;
@@ -107,8 +120,12 @@
       System.out.println("Successful classes:    " + result.getSuccess());
       System.out.println("Failed classes:        " + result.getFailed());
       System.out.println("Wrong loader (filter): " + result.getBadFilter());
+      
+      if (result.getFailed() > result.getSuccess())
+         fail("A lot of failures!");
    }
    
+   
    private void loadClasses(ClassLoaderInfo info, String[] names)
    {
       for (int i = 0 ; i < names.length ; i++)
@@ -116,4 +133,13 @@
          info.loadClass(names[i]);
       }
    }
+   
+   protected ClassLoaderInfo createClassLoaderInfo(ClassPathElementInfo elementInfo, VFSClassLoaderFactory factory, String...classesToLoad)
+   {
+      ClassLoaderInfo info = new ClassLoaderInfo(elementInfo, factory);
+      info.addClassesToLoad(classesToLoad);
+      
+      return info;
+   }
+   
 }

Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmarkTestDelegate.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmarkTestDelegate.java	                        (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmarkTestDelegate.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -0,0 +1,287 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.cl.benchmark;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javassist.Modifier;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.ClassFileWriter;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.Opcode;
+import javassist.bytecode.ClassFileWriter.ConstPoolWriter;
+import javassist.bytecode.ClassFileWriter.MethodWriter;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractClassLoaderBenchmarkTestDelegate extends MicrocontainerTestDelegate
+{
+   private List<ClassPathElementInfo> classPathElements = new ArrayList<ClassPathElementInfo>();
+   
+   protected final File classesDir;
+   
+   protected final File jarsDir;
+   
+   public AbstractClassLoaderBenchmarkTestDelegate(Class<?> clazz) throws Exception
+   {
+      super(clazz);
+      
+      URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
+      File file = new File(url.toURI());
+      if (!file.exists())
+         throw new IllegalStateException("Could not find file " + file);
+      if (!file.isDirectory())
+         throw new IllegalStateException(file + " is not a directory");
+      
+      classesDir = new File(file.getParentFile(), "generated-classes"); 
+      jarsDir = new File(file.getParentFile(), "generated-jars");
+   }
+   
+   @Override
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      
+      URL commonUrl = getClass().getResource("/org/jboss/test/cl/benchmark/Common.xml");
+      if (commonUrl == null)
+         throw new IllegalStateException("Null common url");
+      deploy(commonUrl);      
+      
+      if (!createDirectoriesIfNotExist())
+      {
+         System.out.println("No " + classesDir + " or " + jarsDir + " found. Generating classes...");
+         createClassesAndJars();
+      }
+      else
+      {
+         System.out.println(classesDir + " or " + jarsDir + " found. Using existing jars");         
+      }
+      
+      createClassPathElementInfos();
+   }
+   
+   protected boolean createDirectoriesIfNotExist()
+   {
+      boolean exists = false;
+      if (!classesDir.exists())
+         classesDir.mkdir();
+      else
+         exists = true;
+      
+      if (!jarsDir.exists())
+         jarsDir.mkdir();
+      else
+         exists = true;
+      
+      return exists;
+   }
+   
+   protected abstract void createClassesAndJars() throws Exception;
+   
+   protected abstract void createClassPathElementInfos() throws Exception;
+   
+   
+   List<ClassPathElementInfo> getClassPathElements()
+   {
+      return Collections.unmodifiableList(classPathElements);
+   }
+   
+   ClassLoader install(VFSClassLoaderFactory factory) throws Exception
+   {
+      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+      deployment.setName(factory.getName() + ":" + factory.getVersion());
+      deployment.setBeanFactories(Collections.singletonList((BeanMetaDataFactory) factory));
+      deploy(deployment);
+      
+      Object object = getBean(getContextName(factory), ControllerState.INSTALLED);
+      if (object instanceof ClassLoader == false)
+         throw new AssertionFailedError(object + " is not a classloader");
+      
+      return (ClassLoader)object;
+   }
+
+   protected String getContextName(VFSClassLoaderFactory factory)
+   {
+      String contextName = factory.getContextName();
+      if (contextName == null)
+         contextName = factory.getName() + ":" + factory.getVersion();
+      return contextName;
+   }
+   
+   protected void addClassPathElement(ClassPathElementInfo info)
+   {
+      classPathElements.add(info);
+   }
+   
+   protected void createJar(String name, File classesDir) throws IOException
+   {
+      JavaArchive archive = ShrinkWrap.create(name, JavaArchive.class);
+
+      ArchivePath path = ArchivePaths.create("/");
+      addDirectoryToJar(archive, path, classesDir);
+      
+      //System.out.println(archive.toString(true));
+      
+      archive.as(ZipExporter.class).exportZip(new File(jarsDir, name), true);
+      
+      cleanDirectory(classesDir);
+   }
+   
+   protected ClassPathElementInfo createClassPathElementInfo(String name, List<String> packages, List<String> classNames, boolean load, ClassPathElementInfo...imports)
+         throws Exception
+   {
+      URL url = new File(jarsDir, name).toURI().toURL();
+      ClassPathElementInfo info = new ClassPathElementInfo(name, url, packages, classNames, load);
+      for (ClassPathElementInfo imported : imports)
+         info.addImportedJar(imported);
+      return info;
+   }
+
+   protected void createInterface(String name, String...interfaces) throws Exception
+   {
+      createClass(true, name, Object.class.getName(), interfaces);
+   }
+
+   protected void createClass(String name, String superclass, String...interfaces) throws Exception
+   {
+      createClass(false, name, superclass, interfaces);
+   }
+
+   private void createClass(boolean isInterface, String name, String superclass, String...interfaces) throws Exception
+   {
+      name = name.replace('.', '/');
+      ClassFileWriter clazz = new ClassFileWriter(ClassFile.JAVA_5, 0);   
+      ConstPoolWriter cp = clazz.getConstPool();
+      int thisClass = cp.addClassInfo(name);
+      int superClazz = cp.addClassInfo(superclass.replace('.', '/'));
+      String[] ifaces = new String[interfaces.length];
+      for (int i = 0 ; i < ifaces.length ; i++)
+         ifaces[i] = interfaces[i].replace('.', '/');
+      int[] ifacez = cp.addClassInfo(ifaces);
+      
+      if (!isInterface)
+      {
+         //Add default constructor
+         MethodWriter mw = clazz.getMethodWriter();   
+         mw.begin(Modifier.PUBLIC, MethodInfo.nameInit, "()V",  null, null);
+         mw.add(Opcode.ALOAD_0);
+         mw.add(Opcode.INVOKESPECIAL);
+         int signature = cp.addNameAndTypeInfo(MethodInfo.nameInit, "()V");
+         mw.add16(cp.addMethodrefInfo(superClazz, signature));
+         mw.add(Opcode.RETURN);
+         mw.codeEnd(1, 1);
+         mw.end(null, null);
+      }
+      
+      int modifier = isInterface ? Modifier.PUBLIC | Modifier.INTERFACE | Modifier.ABSTRACT : Modifier.PUBLIC;
+      
+      byte[] bytes = clazz.end(modifier, thisClass, superClazz, ifacez, null);
+      
+      
+      File file = classesDir;
+      String[] nameElements = name.split("/");
+      for (int i = 0 ; i < nameElements.length ; i++)
+      {
+         if (i < nameElements.length - 1)
+         {
+            file = new File(file, nameElements[i]);
+            if (!file.exists())
+               file.mkdir();
+         }
+         else
+         {
+            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(file, nameElements[i] + ".class")));
+            try
+            {
+               out.write(bytes);
+            }
+            finally
+            {
+               if (out != null)
+               {
+                  try
+                  {
+                     out.close();
+                  }
+                  catch(IOException ignore)
+                  {
+                  }
+               }
+            }
+         }
+      }
+   }
+
+   private static void addDirectoryToJar(JavaArchive archive, ArchivePath currentPath, File currentDir)
+   {
+      String[] files = currentDir.list();
+      for (String fileName : files)
+      {
+         ArchivePath filePath = ArchivePaths.create(currentPath, fileName);
+         File file = new File(currentDir, fileName);
+         if (file.isDirectory())
+         {
+            addDirectoryToJar(archive, filePath, file);
+         }
+         else
+         {
+            archive.addResource(file, filePath);
+         }
+      }
+   }
+   
+   protected static void cleanDirectory(File currentDir)
+   {
+      String[] files = currentDir.list();
+      for (String fileName : files)
+      {
+         File file = new File(currentDir, fileName);
+         if (file.isDirectory())
+            cleanDirectory(file);
+
+         file.delete();
+      }
+   }
+}

Deleted: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderBenchmarkTestDelegate.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderBenchmarkTestDelegate.java	2010-07-21 06:30:38 UTC (rev 106973)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderBenchmarkTestDelegate.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -1,169 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.test.cl.benchmark;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import javax.resource.spi.IllegalStateException;
-
-import junit.framework.AssertionFailedError;
-
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
-import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ClassLoaderBenchmarkTestDelegate extends MicrocontainerTestDelegate
-{
-   private List<ClassPathElementInfo> classPathElements = new ArrayList<ClassPathElementInfo>();
-   
-   public ClassLoaderBenchmarkTestDelegate(Class<?> clazz) throws Exception
-   {
-      super(clazz);
-   }
-   
-   @Override
-   public void setUp() throws Exception
-   {
-      super.setUp();
-      
-      String classpath = System.getProperty("java.class.path");
-      String[] jars = classpath.split(File.pathSeparator);
-      
-      createClassPathElements(jars);
-      
-      URL commonUrl = getClass().getResource("/org/jboss/test/cl/benchmark/Common.xml");
-      if (commonUrl == null)
-         throw new IllegalStateException("Null common url");
-      deploy(commonUrl);      
-   }
-   
-   private void createClassPathElements(String[] jars) throws IOException
-   {
-      Set<String> doneAlready = new HashSet<String>();
-      int skippedPackages = 0;
-      int skippedClasses = 0;
-      int packages = 0;
-      int classes = 0;
-      int noclasses = 0;
-      for (String jar : jars)
-      {
-         if (isJar(jar))
-         {
-            File file = new File(jar);
-            if (!file.exists())
-               throw new IllegalArgumentException("Could not find " + file);
-
-            List<String> classNames = new ArrayList<String>();
-            List<String> packageNames = new ArrayList<String>();
-            JarFile jarFile = new JarFile(file);
-            for (Enumeration<JarEntry> e = jarFile.entries() ; e.hasMoreElements() ; )
-            {
-               JarEntry entry = e.nextElement();
-               
-               //TODO - replace '/' with '.'?
-               if (entry.getName().endsWith("/")) 
-               {
-                  if (doneAlready.contains(entry.getName()))
-                  {
-                     skippedPackages++;
-                     continue;
-                  }
-                  packageNames.add(entry.getName().replace('/', '.'));
-               }
-               else if (entry.getName().endsWith(".class"))
-               {
-                  if (doneAlready.contains(entry.getName()))
-                  {
-                     skippedClasses++;
-                     continue;
-                  }
-                  classNames.add(entry.getName().substring(0, entry.getName().indexOf(".class")).replace('/', '.'));
-               }
-
-               doneAlready.add(entry.getName());
-            }
-            
-            
-            if (classNames.size() > 0)
-            {
-               classPathElements.add(new ClassPathElementInfo(jar, new File(jar).toURI().toURL(), packageNames, classNames));
-               packages += packageNames.size();
-               classes += classNames.size();
-            }
-            else
-               noclasses++;
-         }
-      }
-      System.out.println(classPathElements.size() + " jars indexed. Classes: " + classes + ". Packages: " + packages + 
-            ". Excluded: (Empty jars: " + noclasses + ". Duplicate packages: " + skippedPackages + ". Duplicate classes: " + skippedClasses + ")");
-   }
-   
-
-   List<ClassPathElementInfo> getClassPathElements()
-   {
-      return Collections.unmodifiableList(classPathElements);
-   }
-   
-   ClassLoader install(VFSClassLoaderFactory factory) throws Exception
-   {
-      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
-      deployment.setName(factory.getName() + ":" + factory.getVersion());
-      deployment.setBeanFactories(Collections.singletonList((BeanMetaDataFactory) factory));
-      deploy(deployment);
-      
-      Object object = getBean(getContextName(factory), ControllerState.INSTALLED);
-      if (object instanceof ClassLoader == false)
-         throw new AssertionFailedError(object + " is not a classloader");
-      
-      return (ClassLoader)object;
-   }
-
-   protected String getContextName(VFSClassLoaderFactory factory)
-   {
-      String contextName = factory.getContextName();
-      if (contextName == null)
-         contextName = factory.getName() + ":" + factory.getVersion();
-      return contextName;
-   }
-
-   static boolean isJar(String name)
-   {
-      return name.endsWith(".jar");
-   }
-}

Modified: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java	2010-07-21 06:30:38 UTC (rev 106973)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -22,7 +22,6 @@
 package org.jboss.test.cl.benchmark;
 
 import java.net.URL;
-import java.util.List;
 
 import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
 
@@ -40,9 +39,8 @@
    private ClassLoader loader;
    private LoadingResult result;
    private String[] classesToLoad;
-   private ClassLoaderInfo loaderWhoseClassesToLoad;
    
-   public ClassLoaderInfo(ClassPathElementInfo info, VFSClassLoaderFactory factory)
+   ClassLoaderInfo(ClassPathElementInfo info, VFSClassLoaderFactory factory)
    {
       this.elementInfo = info;
       this.factory = factory;
@@ -53,32 +51,30 @@
       return factory;
    }
    
-   void initialize(LoadingResult result, ClassLoader loader, int num)
+   void initialize(LoadingResult result, ClassLoader loader)
    {
       this.loader = loader;
       this.result = result;
-      
-      if (classesToLoad != null)
-         return;
-      
-      List<String> all = elementInfo.getClassNames();
-      
-      if (all.size() <= num)
-         classesToLoad = all.toArray(new String[all.size()]);
-      else
+   }
+   
+   void addClassesToLoad(String...classes)
+   {
+      if (classesToLoad == null)
+         classesToLoad = classes;
+      else 
       {
-         int index = all.size() / 2;
-         classesToLoad = new String[num];
-         for (int i = 0 ; i < num ; i++)
-         {
-            index += i * (i % 2 == 1 ? -1 : +1);
-            //int j = (i * (i % 2 == 1 ? -1 : +1) + index); 
-            classesToLoad[i] = all.get(index);
-         }
+         String[] tmp = new String[classesToLoad.length + classes.length];
+         System.arraycopy(classesToLoad, 0, tmp, 0, classesToLoad.length);
+         System.arraycopy(classes, 0, tmp, 0, classes.length);
+         classesToLoad = tmp;
       }
-      
    }
    
+   boolean isLoadClasses()
+   {
+      return elementInfo.isLoadClasses();
+   }
+   
    public void loadClass(String className)
    {
       try
@@ -100,17 +96,12 @@
       
    }
 
-   List<String> getClassNames()
-   {
-      return elementInfo.getClassNames();
-   }
-
    public String getName()
    {
       return elementInfo.getName();
    }
 
-   public List<String> getPackageNames()
+   public String[] getPackageNames()
    {
       return elementInfo.getPackageNames();
    }
@@ -120,21 +111,9 @@
       return elementInfo.getUrl();
    }
    
-   public void setLoaderWhoseClassesToLoad(ClassLoaderInfo other)
+   public String[] getClassesToLoad()
    {
-      loaderWhoseClassesToLoad = other;
-   }
-
-   public String[] getOwnClassesToLoad()
-   {
       return classesToLoad;
    }
 
-   public String[] getOtherClassesToLoad()
-   {
-      if (loaderWhoseClassesToLoad != null)
-         return loaderWhoseClassesToLoad.classesToLoad;
-      return classesToLoad;
-   }
-   
 }

Modified: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java	2010-07-21 06:30:38 UTC (rev 106973)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -22,6 +22,7 @@
 package org.jboss.test.cl.benchmark;
 
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -33,24 +34,31 @@
 {
    private final String name;
    private final URL url;
-   private final List<String> packageNames;
-   private final List<String> classNames;
+   private final String[] packageNames;
+   private final String[] classNames;
+   private final boolean loadClasses;
+   private final List<ClassPathElementInfo> importedJars = new ArrayList<ClassPathElementInfo>();
 
-   ClassPathElementInfo(String name, URL url, List<String> packageNames, List<String> classNames)
+   ClassPathElementInfo(String name, URL url, List<String> packageNames, List<String> classNames, boolean loadClasses)
    {
       this.name = name;
-      this.packageNames = packageNames;
-      this.classNames = classNames;
+      this.packageNames = packageNames.toArray(new String[packageNames.size()]);
+      this.classNames = classNames.toArray(new String[classNames.size()]);
       this.url = url;
+      this.loadClasses = loadClasses;
    }
    
+   public boolean isLoadClasses()
+   {
+      return loadClasses;
+   }
 
-   public List<String> getPackageNames()
+   public String[] getPackageNames()
    {
       return packageNames;
    }
 
-   public List<String> getClassNames()
+   public String[] getClassNames()
    {
       return classNames;
    }
@@ -64,5 +72,15 @@
    {
       return url;
    }
+   
+   void addImportedJar(ClassPathElementInfo imported)
+   {
+      importedJars.add(imported);
+   }
+   
+   public List<ClassPathElementInfo> getImportedJars()
+   {
+      return importedJars;
+   }
 
 }

Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepClassLoaderBenchmarkTestDelegate.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepClassLoaderBenchmarkTestDelegate.java	                        (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepClassLoaderBenchmarkTestDelegate.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -0,0 +1,176 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.cl.benchmark;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThreeDeepClassLoaderBenchmarkTestDelegate extends AbstractClassLoaderBenchmarkTestDelegate
+{
+   final static int NUMBER_JARS = 50;
+   final static int PACKAGES_PER_JAR = 10;
+   final static int CLASSES_PER_PACKAGE = 10;
+
+   public ThreeDeepClassLoaderBenchmarkTestDelegate(Class<?> clazz) throws Exception
+   {
+      super(clazz);
+   }
+
+   @Override
+   protected void createClassesAndJars() throws Exception
+   {
+      createInterfaces();
+      createAbstractImplClasses();
+      createImplClasses();
+   }
+   
+   @Override
+   protected void createClassPathElementInfos() throws Exception
+   {
+      for (int jar = 0 ; jar < NUMBER_JARS ; jar++)
+      {
+         List<String> interfacePackages = new ArrayList<String>();
+         List<String> interfaces = new ArrayList<String>();
+         List<String> abstractImplPackages = new ArrayList<String>();
+         List<String> abstractImplClasses = new ArrayList<String>();
+         List<String> implPackages = new ArrayList<String>();
+         List<String> implClasses = new ArrayList<String>();
+         
+         for (int pkg = 0 ; pkg < PACKAGES_PER_JAR ; pkg++)
+         {
+            interfacePackages.add(getInterfacePkg(jar, pkg));
+            abstractImplPackages.add(getAbstractImplPkg(jar, pkg));
+            implPackages.add(getImplPkg(jar, pkg));
+            for (int clazz = 0 ; clazz < CLASSES_PER_PACKAGE ; clazz++)
+            {
+               interfaces.add(getInterfaceName(jar, pkg, clazz));
+               abstractImplClasses.add(getAbstractImplName(jar, pkg, clazz));
+               implClasses.add(getImplName(jar, pkg, clazz));
+            }
+         }
+         ClassPathElementInfo iface = createClassPathElementInfo(getInterfaceJarName(jar), interfacePackages, interfaces, false);
+         addClassPathElement(iface);
+         
+         ClassPathElementInfo abstractImpl = createClassPathElementInfo(getAbstractImplJarName(jar), abstractImplPackages, abstractImplClasses, false, iface);
+         addClassPathElement(abstractImpl);
+         
+         ClassPathElementInfo impl = createClassPathElementInfo(getImplJarName(jar), implPackages, implClasses, true, abstractImpl);
+         addClassPathElement(impl);
+      }
+   }
+   
+   private void createInterfaces() throws Exception
+   {
+      for (int jar = 0 ; jar < NUMBER_JARS ; jar++)
+      {
+         for (int pkg = 0 ; pkg < PACKAGES_PER_JAR ; pkg++)
+         {
+            for (int clazz = 0 ; clazz < CLASSES_PER_PACKAGE ; clazz++)
+            {
+               createInterface(getInterfaceName(jar, pkg, clazz));
+            }
+         }
+         createJar(getInterfaceJarName(jar), classesDir);
+      }
+   }
+   
+   private void createAbstractImplClasses() throws Exception
+   {
+      for (int jar = 0 ; jar < NUMBER_JARS ; jar++)
+      {
+         for (int pkg = 0 ; pkg < PACKAGES_PER_JAR ; pkg++)
+         {
+            for (int clazz = 0 ; clazz < CLASSES_PER_PACKAGE ; clazz++)
+            {
+               createClass(getAbstractImplName(jar, pkg, clazz), Object.class.getName(), getInterfaceName(jar, pkg, clazz));
+            }
+         }
+         createJar(getAbstractImplJarName(jar), classesDir);
+      }
+   }
+   
+   private void createImplClasses() throws Exception
+   {
+      for (int jar = 0 ; jar < NUMBER_JARS ; jar++)
+      {
+         for (int pkg = 0 ; pkg < PACKAGES_PER_JAR ; pkg++)
+         {
+            for (int clazz = 0 ; clazz < CLASSES_PER_PACKAGE ; clazz++)
+            {
+               createClass(getImplName(jar, pkg, clazz), getAbstractImplName(jar, pkg, clazz));
+            }
+         }
+         createJar(getImplJarName(jar), classesDir);
+      }
+   }
+   
+   private String getInterfaceJarName(int jar)
+   {
+      return "interface" + jar + ".jar";
+   }
+   
+   private String getInterfacePkg(int jar, int pkg)
+   {
+      return "org.jboss.test.interface" + jar + ".pkg" + pkg;
+   }
+   
+   private String getInterfaceName(int jar, int pkg, int clazz)
+   {
+      return getInterfacePkg(jar, pkg) + ".Interface" + clazz;
+   }
+
+   private String getAbstractImplJarName(int jar)
+   {
+      return "abstractimpl" + jar + ".jar";
+   }
+   
+   private String getAbstractImplPkg(int jar, int pkg)
+   {
+      return "org.jboss.test.abstract" + jar + ".pkg" + pkg;
+   }
+   
+   private String getAbstractImplName(int jar, int pkg, int clazz)
+   {
+      return getAbstractImplPkg(jar, pkg) + ".AbstractImpl" + clazz;
+   }
+
+   private String getImplJarName(int jar)
+   {
+      return "impl" + jar + ".jar";
+   }
+   
+   private String getImplPkg(int jar, int pkg)
+   {
+      return "org.jboss.test.impl" + jar + ".pkg" + pkg;
+   }
+   
+   private String getImplName(int jar, int pkg, int clazz)
+   {
+      return getImplPkg(jar, pkg) + ".Impl" + clazz;
+   }
+}

Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/AbstractThreeDeepClassLoaderBenchmark.java (from rev 106950, projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassPathElementInfo.java)
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/AbstractThreeDeepClassLoaderBenchmark.java	                        (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/AbstractThreeDeepClassLoaderBenchmark.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.cl.benchmark.test;
+
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.cl.benchmark.AbstractClassLoaderBenchmark;
+import org.jboss.test.cl.benchmark.ThreeDeepClassLoaderBenchmarkTestDelegate;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractThreeDeepClassLoaderBenchmark extends AbstractClassLoaderBenchmark
+{
+   public AbstractThreeDeepClassLoaderBenchmark(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class<?> clazz)
+   {
+      try
+      {
+         return new ThreeDeepClassLoaderBenchmarkTestDelegate(clazz);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+}

Deleted: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOtherAlreadyLoadedBenchmarkTestCase.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOtherAlreadyLoadedBenchmarkTestCase.java	2010-07-21 06:30:38 UTC (rev 106973)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOtherAlreadyLoadedBenchmarkTestCase.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -1,78 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.test.cl.benchmark.test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.classloading.spi.metadata.ExportAll;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
-import org.jboss.test.cl.benchmark.AbstractClassLoaderBenchmark;
-import org.jboss.test.cl.benchmark.BenchmarkScenario;
-import org.jboss.test.cl.benchmark.ClassPathElementInfo;
-import org.jboss.test.cl.benchmark.ClassLoaderInfo;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ImportExportAllOtherAlreadyLoadedBenchmarkTestCase extends AbstractClassLoaderBenchmark
-{
-   public ImportExportAllOtherAlreadyLoadedBenchmarkTestCase(String name)
-   {
-      super(name);
-   }
-   
-   public void testLoadClassesFromOtherLoaderAlreadyLoader() throws Exception
-   {
-      runBenchmark(new BenchmarkScenario()
-      {
-         
-         public List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
-         {
-            List<ClassLoaderInfo> classLoaderInfos = new ArrayList<ClassLoaderInfo>();
-            
-            ClassLoaderInfo last = null;
-            for (ClassPathElementInfo info : infos)
-            {
-               VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
-               factory.setExportAll(ExportAll.NON_EMPTY);
-               factory.setImportAll(true);
-               factory.getRoots().add(info.getUrl().toString());
-               //Needed???
-               //factory.setIncludedPackages()
-               
-               ClassLoaderInfo classLoaderInfo = new ClassLoaderInfo(info, factory);
-               classLoaderInfos.add(classLoaderInfo);
-               
-               if (last != null)
-                  classLoaderInfo.setLoaderWhoseClassesToLoad(last);
-            }      
-            
-            
-            classLoaderInfos.get(0).setLoaderWhoseClassesToLoad(classLoaderInfos.get(classLoaderInfos.size() - 1));
-            return classLoaderInfos;
-         }
-      });
-   }
-}

Deleted: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOtherNotAlreadyLoadedBenchmarkTestCase.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOtherNotAlreadyLoadedBenchmarkTestCase.java	2010-07-21 06:30:38 UTC (rev 106973)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOtherNotAlreadyLoadedBenchmarkTestCase.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -1,77 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.test.cl.benchmark.test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.classloading.spi.metadata.ExportAll;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
-import org.jboss.test.cl.benchmark.AbstractClassLoaderBenchmark;
-import org.jboss.test.cl.benchmark.BenchmarkScenario;
-import org.jboss.test.cl.benchmark.ClassPathElementInfo;
-import org.jboss.test.cl.benchmark.ClassLoaderInfo;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ImportExportAllOtherNotAlreadyLoadedBenchmarkTestCase extends AbstractClassLoaderBenchmark
-{
-   public ImportExportAllOtherNotAlreadyLoadedBenchmarkTestCase(String name)
-   {
-      super(name);
-   }
-   
-   public void testLoadClassesFromOtherLoaderAlreadyLoader() throws Exception
-   {
-      runBenchmark(new BenchmarkScenario()
-      {
-         
-         public List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
-         {
-            List<ClassLoaderInfo> classLoaderInfos = new ArrayList<ClassLoaderInfo>();
-            
-            ClassLoaderInfo last = null;
-            for (ClassPathElementInfo info : infos)
-            {
-               VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
-               factory.setExportAll(ExportAll.NON_EMPTY);
-               factory.setImportAll(true);
-               factory.getRoots().add(info.getUrl().toString());
-               //Needed???
-               //factory.setIncludedPackages()
-               
-               ClassLoaderInfo classLoaderInfo = new ClassLoaderInfo(info, factory);
-               classLoaderInfos.add(classLoaderInfo);
-               
-               if (last != null)
-                  last.setLoaderWhoseClassesToLoad(classLoaderInfo);
-            }      
-            
-            classLoaderInfos.get(classLoaderInfos.size() - 1).setLoaderWhoseClassesToLoad(classLoaderInfos.get(0));
-            return classLoaderInfos;
-         }
-      });
-   }
-}

Deleted: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java	2010-07-21 06:30:38 UTC (rev 106973)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -1,71 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.test.cl.benchmark.test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.classloading.spi.metadata.ExportAll;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
-import org.jboss.test.cl.benchmark.AbstractClassLoaderBenchmark;
-import org.jboss.test.cl.benchmark.BenchmarkScenario;
-import org.jboss.test.cl.benchmark.ClassPathElementInfo;
-import org.jboss.test.cl.benchmark.ClassLoaderInfo;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ImportExportAllOwnLoaderBenchmarkTestCase extends AbstractClassLoaderBenchmark
-{
-   public ImportExportAllOwnLoaderBenchmarkTestCase(String name)
-   {
-      super(name);
-   }
-   
-   public void testLoadClassesFromOwnLoader() throws Exception
-   {
-      runBenchmark(new BenchmarkScenario()
-      {
-         
-         public List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
-         {
-            List<ClassLoaderInfo> deploymentInfos = new ArrayList<ClassLoaderInfo>();
-            
-            for (ClassPathElementInfo info : infos)
-            {
-               VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
-               factory.setExportAll(ExportAll.NON_EMPTY);
-               factory.setImportAll(true);
-               factory.getRoots().add(info.getUrl().toString());
-               //Needed???
-               //factory.setIncludedPackages()
-               
-               deploymentInfos.add(new ClassLoaderInfo(info, factory));
-            }      
-            
-            return deploymentInfos;
-         }
-      });
-   }
-}

Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportExportAllOwnLoaderBenchmarkTestCase.java (from rev 106950, projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ImportExportAllOwnLoaderBenchmarkTestCase.java)
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportExportAllOwnLoaderBenchmarkTestCase.java	                        (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportExportAllOwnLoaderBenchmarkTestCase.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -0,0 +1,70 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.cl.benchmark.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.test.cl.benchmark.BenchmarkScenario;
+import org.jboss.test.cl.benchmark.ClassLoaderInfo;
+import org.jboss.test.cl.benchmark.ClassPathElementInfo;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThreeDeepImportExportAllOwnLoaderBenchmarkTestCase extends AbstractThreeDeepClassLoaderBenchmark
+{
+   public ThreeDeepImportExportAllOwnLoaderBenchmarkTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testLoadClassesFromOwnLoader() throws Exception
+   {
+      runBenchmark(new BenchmarkScenario()
+      {
+         
+         public List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
+         {
+            List<ClassLoaderInfo> deploymentInfos = new ArrayList<ClassLoaderInfo>();
+            
+            for (ClassPathElementInfo info : infos)
+            {
+               VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+               factory.setExportAll(ExportAll.NON_EMPTY);
+               factory.setImportAll(true);
+               factory.getRoots().add(info.getUrl().toString());
+               //Needed???
+               //factory.setIncludedPackages()
+               
+               deploymentInfos.add(createClassLoaderInfo(info, factory, info.getClassNames()));
+            }      
+            
+            return deploymentInfos;
+         }
+      });
+   }
+}

Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportModuleLoaderBenchmarkTestCase.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportModuleLoaderBenchmarkTestCase.java	                        (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportModuleLoaderBenchmarkTestCase.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.cl.benchmark.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.test.cl.benchmark.BenchmarkScenario;
+import org.jboss.test.cl.benchmark.ClassLoaderInfo;
+import org.jboss.test.cl.benchmark.ClassPathElementInfo;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThreeDeepImportModuleLoaderBenchmarkTestCase extends AbstractThreeDeepClassLoaderBenchmark
+{
+   public ThreeDeepImportModuleLoaderBenchmarkTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testLoadClassesFromOwnLoader() throws Exception
+   {
+      runBenchmark(new BenchmarkScenario()
+      {
+         
+         public List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
+         {
+            List<ClassLoaderInfo> deploymentInfos = new ArrayList<ClassLoaderInfo>();
+            
+            for (ClassPathElementInfo info : infos)
+            {
+               if (!info.isLoadClasses())
+                  continue;
+
+               ClassPathElementInfo parent = info.getImportedJars().get(0);
+               ClassPathElementInfo grandParent = parent.getImportedJars().get(0);
+               
+               deploymentInfos.add(createGrandParent(grandParent));
+               deploymentInfos.add(createParent(parent, grandParent));
+               deploymentInfos.add(createImpl(info, parent));
+            }      
+            
+            return deploymentInfos;
+         }
+      });
+   }
+
+   ClassLoaderInfo createGrandParent(ClassPathElementInfo info)
+   {
+      VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+      ClassLoadingMetaDataFactory metaData = ClassLoadingMetaDataFactory.getInstance();
+      factory.getCapabilities().addCapability(metaData.createModule(info.getName()));
+      factory.getRoots().add(info.getUrl().toString());
+      
+      return createClassLoaderInfo(info, factory, info.getClassNames());
+      
+   }
+   
+   ClassLoaderInfo createParent(ClassPathElementInfo info, ClassPathElementInfo grandParent)
+   {
+      VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+      ClassLoadingMetaDataFactory metaData = ClassLoadingMetaDataFactory.getInstance();
+      factory.getCapabilities().addCapability(metaData.createModule(info.getName()));
+      factory.getRequirements().addRequirement(metaData.createReExportModule(grandParent.getName()));
+      factory.getRoots().add(info.getUrl().toString());
+      
+      return createClassLoaderInfo(info, factory, info.getClassNames());
+   }
+   
+   ClassLoaderInfo createImpl(ClassPathElementInfo info, ClassPathElementInfo parent)
+   {
+      VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+      ClassLoadingMetaDataFactory metaData = ClassLoadingMetaDataFactory.getInstance();
+      factory.getRequirements().addRequirement(metaData.createReExportModule(parent.getName()));
+      factory.getRoots().add(info.getUrl().toString());
+      
+      return createClassLoaderInfo(info, factory, info.getClassNames());
+   }
+}

Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportPackageLoaderBenchmarkTestCase.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportPackageLoaderBenchmarkTestCase.java	                        (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportPackageLoaderBenchmarkTestCase.java	2010-07-21 11:29:38 UTC (rev 106974)
@@ -0,0 +1,107 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.cl.benchmark.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.test.cl.benchmark.BenchmarkScenario;
+import org.jboss.test.cl.benchmark.ClassLoaderInfo;
+import org.jboss.test.cl.benchmark.ClassPathElementInfo;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThreeDeepImportPackageLoaderBenchmarkTestCase extends AbstractThreeDeepClassLoaderBenchmark
+{
+   public ThreeDeepImportPackageLoaderBenchmarkTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testLoadClassesFromOwnLoader() throws Exception
+   {
+      runBenchmark(new BenchmarkScenario()
+      {
+         
+         public List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
+         {
+            List<ClassLoaderInfo> deploymentInfos = new ArrayList<ClassLoaderInfo>();
+            
+            for (ClassPathElementInfo info : infos)
+            {
+               if (!info.isLoadClasses())
+                  continue;
+
+               ClassPathElementInfo parent = info.getImportedJars().get(0);
+               ClassPathElementInfo grandParent = parent.getImportedJars().get(0);
+               
+               deploymentInfos.add(createGrandParent(grandParent));
+               deploymentInfos.add(createParent(parent, grandParent));
+               deploymentInfos.add(createImpl(info, parent));
+            }      
+            
+            return deploymentInfos;
+         }
+      });
+   }
+
+   ClassLoaderInfo createGrandParent(ClassPathElementInfo info)
+   {
+      VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+      ClassLoadingMetaDataFactory metaData = ClassLoadingMetaDataFactory.getInstance();
+      for (String pkg : info.getPackageNames())
+         factory.getCapabilities().addCapability(metaData.createPackage(pkg));
+      factory.getRoots().add(info.getUrl().toString());
+      
+      return createClassLoaderInfo(info, factory, info.getClassNames());
+      
+   }
+   
+   ClassLoaderInfo createParent(ClassPathElementInfo info, ClassPathElementInfo grandParent)
+   {
+      VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+      ClassLoadingMetaDataFactory metaData = ClassLoadingMetaDataFactory.getInstance();
+      for (String pkg : info.getPackageNames())
+         factory.getCapabilities().addCapability(metaData.createPackage(pkg));
+      for (String pkg : grandParent.getPackageNames())
+         factory.getRequirements().addRequirement(metaData.createReExportPackage(pkg));
+      factory.getRoots().add(info.getUrl().toString());
+      
+      return createClassLoaderInfo(info, factory, info.getClassNames());
+   }
+   
+   ClassLoaderInfo createImpl(ClassPathElementInfo info, ClassPathElementInfo parent)
+   {
+      VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+      ClassLoadingMetaDataFactory metaData = ClassLoadingMetaDataFactory.getInstance();
+      for (String pkg : parent.getPackageNames())
+         factory.getRequirements().addRequirement(metaData.createReExportPackage(pkg));
+      factory.getRoots().add(info.getUrl().toString());
+      
+      return createClassLoaderInfo(info, factory, info.getClassNames());
+   }
+}



More information about the jboss-cvs-commits mailing list