[jboss-cvs] JBossAS SVN: r107048 - in projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark: test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 23 05:46:38 EDT 2010
Author: kabir.khan at jboss.com
Date: 2010-07-23 05:46:37 -0400 (Fri, 23 Jul 2010)
New Revision: 107048
Added:
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractTestSetCreator.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractVFSCLassLoaderBenchmarkTestDelegate.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractVFSClassLoaderBenchmark.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepTestSetCreator.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepVFSClassLoaderBenchmarkTestDelegate.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/VFSClassLoaderInfo.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/AbstractThreeDeepVFSClassLoaderBenchmark.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportExportAllOwnLoaderBenchmarkTestCase.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportModuleLoaderBenchmarkTestCase.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportPackageLoaderBenchmarkTestCase.java
Removed:
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
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/AbstractClassLoaderBenchmarkTestDelegate.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java
projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java
Log:
Refactor to more easily be able to test other cl architectures (e.g. jboss-modules) and externalize how the jars are created
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-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmark.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -29,7 +29,6 @@
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;
/**
@@ -37,16 +36,16 @@
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
-public abstract class AbstractClassLoaderBenchmark extends AbstractTestCaseWithSetup
+public abstract class AbstractClassLoaderBenchmark<T extends ClassLoaderInfo> extends AbstractTestCaseWithSetup
{
public AbstractClassLoaderBenchmark(String name)
{
super(name);
}
- protected AbstractClassLoaderBenchmarkTestDelegate getBenchmarkTestDelegate()
+ protected AbstractClassLoaderBenchmarkTestDelegate<T> getBenchmarkTestDelegate()
{
- return (AbstractClassLoaderBenchmarkTestDelegate)getDelegate();
+ return (AbstractClassLoaderBenchmarkTestDelegate<T>)getDelegate();
}
public static ClassLoaderSystem getClassLoaderSystem()
@@ -57,9 +56,9 @@
return system;
}
- private void trimLoadersWithNoClasses(List<ClassLoaderInfo> infos)
+ private void trimLoadersWithNoClasses(List<T> infos)
{
- for (Iterator<ClassLoaderInfo> it = infos.iterator() ; it.hasNext() ; )
+ for (Iterator<T> it = infos.iterator() ; it.hasNext() ; )
{
String[] classes = it.next().getClassesToLoad();
if (classes == null || classes.length == 0)
@@ -67,13 +66,13 @@
}
}
- private List<ClassLoaderInfo> getLoadersForLoading(List<ClassLoaderInfo> infos)
+ private List<ClassLoaderInfo> getLoadersForLoading(List<T> infos)
{
int classes = 0;
List<ClassLoaderInfo> result = new ArrayList<ClassLoaderInfo>();
- for (Iterator<ClassLoaderInfo> it = infos.iterator() ; it.hasNext() ; )
+ for (Iterator<T> it = infos.iterator() ; it.hasNext() ; )
{
- ClassLoaderInfo current = it.next();
+ T current = it.next();
if (current.isLoadClasses())
{
result.add(current);
@@ -84,9 +83,9 @@
return result;
}
- protected void runBenchmark(BenchmarkScenario scenario) throws Exception
+ protected void runBenchmark(BenchmarkScenario<T> scenario) throws Exception
{
- List<ClassLoaderInfo> classLoaderInfos = scenario.createFactories(getBenchmarkTestDelegate().getClassPathElements());
+ List<T> classLoaderInfos = scenario.createFactories(getBenchmarkTestDelegate().getClassPathElements());
System.out.println("Starting run. " + classLoaderInfos.size() + " jars indexed");
trimLoadersWithNoClasses(classLoaderInfos);
@@ -95,8 +94,8 @@
LoadingResult result = new LoadingResult();
long start = System.currentTimeMillis();
- for (ClassLoaderInfo info : classLoaderInfos) {
- info.initialize(result, getBenchmarkTestDelegate().install(info.getFactory()));
+ for (T info : classLoaderInfos) {
+ info.initialize(result, getBenchmarkTestDelegate().createLoader(info));
}
long time = System.currentTimeMillis() - start;
System.out.println("-> Creating " + classLoaderInfos.size() + " class loaders took." + time + "ms");
@@ -129,12 +128,4 @@
}
}
- protected ClassLoaderInfo createClassLoaderInfo(ClassPathElementInfo elementInfo, VFSClassLoaderFactory factory, String...classesToLoad)
- {
- ClassLoaderInfo info = new ClassLoaderInfo(elementInfo, factory);
- info.addClassesToLoad(classesToLoad);
-
- return info;
- }
-
}
Modified: 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 2010-07-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractClassLoaderBenchmarkTestDelegate.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -21,34 +21,10 @@
*/
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;
/**
@@ -56,27 +32,14 @@
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
-public abstract class AbstractClassLoaderBenchmarkTestDelegate extends MicrocontainerTestDelegate
+public abstract class AbstractClassLoaderBenchmarkTestDelegate<T extends ClassLoaderInfo> extends MicrocontainerTestDelegate
{
- private List<ClassPathElementInfo> classPathElements = new ArrayList<ClassPathElementInfo>();
+ AbstractTestSetCreator creator;
- protected final File classesDir;
-
- protected final File jarsDir;
-
- public AbstractClassLoaderBenchmarkTestDelegate(Class<?> clazz) throws Exception
+ public AbstractClassLoaderBenchmarkTestDelegate(Class<?> clazz, AbstractTestSetCreator creator) 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");
+ this.creator = creator;
}
@Override
@@ -88,60 +51,14 @@
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();
+ creator.createClassesAndJars();
}
- 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);
+ return creator.getClassPathElements();
}
- 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();
@@ -150,138 +67,5 @@
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();
- }
- }
+ abstract ClassLoader createLoader(T classLoaderInfo) throws Exception;
}
Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractTestSetCreator.java (from rev 106993, 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/AbstractTestSetCreator.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractTestSetCreator.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -0,0 +1,229 @@
+/*
+* 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.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 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;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractTestSetCreator
+{
+ final static int NUMBER_JARS = 2;
+ final static int PACKAGES_PER_JAR = 2;
+ final static int CLASSES_PER_PACKAGE = 2;
+
+ private List<ClassPathElementInfo> classPathElements = new ArrayList<ClassPathElementInfo>();
+
+ protected final File classesDir;
+
+ protected final File jarsDir;
+
+ AbstractTestSetCreator() throws Exception
+ {
+ 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");
+
+ if (!jarsDir.exists())
+ {
+ if (!classesDir.exists())
+ classesDir.mkdir();
+ jarsDir.mkdir();
+ createClassesAndJars();
+ }
+ createClassPathElementInfos();
+ }
+
+ List<ClassPathElementInfo> getClassPathElements()
+ {
+ return classPathElements;
+ }
+
+ protected abstract void createClassesAndJars() throws Exception;
+
+ protected abstract void createClassPathElementInfos() throws Exception;
+
+ 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();
+ }
+ }
+
+}
Added: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractVFSCLassLoaderBenchmarkTestDelegate.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractVFSCLassLoaderBenchmarkTestDelegate.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractVFSCLassLoaderBenchmarkTestDelegate.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -0,0 +1,60 @@
+/*
+* 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.Collections;
+
+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;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractVFSCLassLoaderBenchmarkTestDelegate extends AbstractClassLoaderBenchmarkTestDelegate<VFSClassLoaderInfo>
+{
+ public AbstractVFSCLassLoaderBenchmarkTestDelegate(Class<?> clazz, AbstractTestSetCreator creator) throws Exception
+ {
+ super(clazz, creator);
+ }
+
+ @Override
+ ClassLoader createLoader(VFSClassLoaderInfo classLoaderInfo) throws Exception
+ {
+ VFSClassLoaderFactory factory = classLoaderInfo.getFactory();
+ 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;
+ }
+}
Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractVFSClassLoaderBenchmark.java (from rev 106993, projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java)
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractVFSClassLoaderBenchmark.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/AbstractVFSClassLoaderBenchmark.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -0,0 +1,46 @@
+/*
+* 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 org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractVFSClassLoaderBenchmark extends AbstractClassLoaderBenchmark<VFSClassLoaderInfo>
+{
+ public AbstractVFSClassLoaderBenchmark(String name)
+ {
+ super(name);
+ }
+
+ protected VFSClassLoaderInfo createClassLoaderInfo(ClassPathElementInfo elementInfo, VFSClassLoaderFactory factory, String...classesToLoad)
+ {
+ VFSClassLoaderInfo info = new VFSClassLoaderInfo(elementInfo, factory);
+ info.addClassesToLoad(classesToLoad);
+
+ return info;
+ }
+
+}
Modified: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java 2010-07-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -28,7 +28,7 @@
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
-public interface BenchmarkScenario
+public interface BenchmarkScenario<T extends ClassLoaderInfo>
{
- List<ClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos);
+ List<T> createFactories(List<ClassPathElementInfo> infos);
}
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-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ClassLoaderInfo.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -23,8 +23,6 @@
import java.net.URL;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
-
/**
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -35,22 +33,16 @@
private static final ClassLoader SYSTEM = ClassLoader.getSystemClassLoader();
private final ClassPathElementInfo elementInfo;
- private final VFSClassLoaderFactory factory;
+ //private final VFSClassLoaderFactory factory;
private ClassLoader loader;
private LoadingResult result;
private String[] classesToLoad;
- ClassLoaderInfo(ClassPathElementInfo info, VFSClassLoaderFactory factory)
+ ClassLoaderInfo(ClassPathElementInfo info)
{
this.elementInfo = info;
- this.factory = factory;
}
- public VFSClassLoaderFactory getFactory()
- {
- return factory;
- }
-
void initialize(LoadingResult result, ClassLoader loader)
{
this.loader = loader;
Deleted: 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 2010-07-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepClassLoaderBenchmarkTestDelegate.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -1,176 +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.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/ThreeDeepTestSetCreator.java (from rev 106993, 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/ThreeDeepTestSetCreator.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepTestSetCreator.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -0,0 +1,173 @@
+/*
+* 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 ThreeDeepTestSetCreator extends AbstractTestSetCreator
+{
+ public ThreeDeepTestSetCreator() throws Exception
+ {
+ super();
+ }
+
+ @Override
+ protected void createClassesAndJars() throws Exception
+ {
+ createInterfaces();
+ createAbstractImplClasses();
+ createImplClasses();
+ }
+
+ @Override
+ protected void createClassPathElementInfos() throws Exception
+ {
+ if (jarsDir.exists())
+ 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/ThreeDeepVFSClassLoaderBenchmarkTestDelegate.java (from rev 106993, projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java)
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepVFSClassLoaderBenchmarkTestDelegate.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/ThreeDeepVFSClassLoaderBenchmarkTestDelegate.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -0,0 +1,43 @@
+/*
+* 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;
+
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThreeDeepVFSClassLoaderBenchmarkTestDelegate extends AbstractVFSCLassLoaderBenchmarkTestDelegate
+{
+ final static int NUMBER_JARS = 2;
+ final static int PACKAGES_PER_JAR = 2;
+ final static int CLASSES_PER_PACKAGE = 2;
+
+ public ThreeDeepVFSClassLoaderBenchmarkTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz, new ThreeDeepTestSetCreator());
+ }
+
+
+}
Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/VFSClassLoaderInfo.java (from rev 106993, projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/BenchmarkScenario.java)
===================================================================
--- projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/VFSClassLoaderInfo.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/VFSClassLoaderInfo.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -0,0 +1,46 @@
+/*
+* 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 org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class VFSClassLoaderInfo extends ClassLoaderInfo
+{
+ VFSClassLoaderFactory factory;
+
+ VFSClassLoaderInfo(ClassPathElementInfo info, VFSClassLoaderFactory factory)
+ {
+ super(info);
+ this.factory = factory;
+ }
+
+ public VFSClassLoaderFactory getFactory()
+ {
+ return factory;
+ }
+
+}
Deleted: 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/AbstractThreeDeepClassLoaderBenchmark.java 2010-07-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/AbstractThreeDeepClassLoaderBenchmark.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -1,52 +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 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);
- }
- }
-
-}
Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/AbstractThreeDeepVFSClassLoaderBenchmark.java (from rev 106993, 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/AbstractThreeDeepVFSClassLoaderBenchmark.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/AbstractThreeDeepVFSClassLoaderBenchmark.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -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.AbstractVFSClassLoaderBenchmark;
+import org.jboss.test.cl.benchmark.ThreeDeepVFSClassLoaderBenchmarkTestDelegate;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractThreeDeepVFSClassLoaderBenchmark extends AbstractVFSClassLoaderBenchmark
+{
+ public AbstractThreeDeepVFSClassLoaderBenchmark(String name)
+ {
+ super(name);
+ }
+
+ public static AbstractTestDelegate getDelegate(Class<?> clazz)
+ {
+ try
+ {
+ return new ThreeDeepVFSClassLoaderBenchmarkTestDelegate(clazz);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Deleted: 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/ThreeDeepImportExportAllOwnLoaderBenchmarkTestCase.java 2010-07-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportExportAllOwnLoaderBenchmarkTestCase.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -1,70 +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.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;
- }
- });
- }
-}
Deleted: 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 2010-07-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportModuleLoaderBenchmarkTestCase.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -1,110 +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.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();
- for (String pkg : info.getPackageNames())
- factory.getCapabilities().addCapability(metaData.createPackage(pkg));
- 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()));
- for (String pkg : info.getPackageNames())
- factory.getCapabilities().addCapability(metaData.createPackage(pkg));
-
- 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();
- for (String pkg : info.getPackageNames())
- factory.getCapabilities().addCapability(metaData.createPackage(pkg));
- factory.getRequirements().addRequirement(metaData.createReExportModule(parent.getName()));
- factory.getRoots().add(info.getUrl().toString());
-
- return createClassLoaderInfo(info, factory, info.getClassNames());
- }
-}
Deleted: 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 2010-07-23 07:48:52 UTC (rev 107047)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepImportPackageLoaderBenchmarkTestCase.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -1,107 +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.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());
- }
-}
Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportExportAllOwnLoaderBenchmarkTestCase.java (from rev 106993, 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/ThreeDeepVFSImportExportAllOwnLoaderBenchmarkTestCase.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportExportAllOwnLoaderBenchmarkTestCase.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -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.ClassPathElementInfo;
+import org.jboss.test.cl.benchmark.VFSClassLoaderInfo;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThreeDeepVFSImportExportAllOwnLoaderBenchmarkTestCase extends AbstractThreeDeepVFSClassLoaderBenchmark
+{
+ public ThreeDeepVFSImportExportAllOwnLoaderBenchmarkTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testLoadClassesFromOwnLoader() throws Exception
+ {
+ runBenchmark(new BenchmarkScenario<VFSClassLoaderInfo>()
+ {
+
+ public List<VFSClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
+ {
+ List<VFSClassLoaderInfo> deploymentInfos = new ArrayList<VFSClassLoaderInfo>();
+
+ 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;
+ }
+ });
+ }
+}
Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportModuleLoaderBenchmarkTestCase.java (from rev 106993, 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/ThreeDeepVFSImportModuleLoaderBenchmarkTestCase.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportModuleLoaderBenchmarkTestCase.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -0,0 +1,110 @@
+/*
+* 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.ClassPathElementInfo;
+import org.jboss.test.cl.benchmark.VFSClassLoaderInfo;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThreeDeepVFSImportModuleLoaderBenchmarkTestCase extends AbstractThreeDeepVFSClassLoaderBenchmark
+{
+ public ThreeDeepVFSImportModuleLoaderBenchmarkTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testLoadClassesFromOwnLoader() throws Exception
+ {
+ runBenchmark(new BenchmarkScenario<VFSClassLoaderInfo>()
+ {
+
+ public List<VFSClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
+ {
+ List<VFSClassLoaderInfo> deploymentInfos = new ArrayList<VFSClassLoaderInfo>();
+
+ 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;
+ }
+ });
+ }
+
+ VFSClassLoaderInfo 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.getCapabilities().addCapability(metaData.createModule(info.getName()));
+ factory.getRoots().add(info.getUrl().toString());
+
+ return createClassLoaderInfo(info, factory, info.getClassNames());
+
+ }
+
+ VFSClassLoaderInfo createParent(ClassPathElementInfo info, ClassPathElementInfo grandParent)
+ {
+ VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+ ClassLoadingMetaDataFactory metaData = ClassLoadingMetaDataFactory.getInstance();
+ factory.getCapabilities().addCapability(metaData.createModule(info.getName()));
+ for (String pkg : info.getPackageNames())
+ factory.getCapabilities().addCapability(metaData.createPackage(pkg));
+
+ factory.getRequirements().addRequirement(metaData.createReExportModule(grandParent.getName()));
+ factory.getRoots().add(info.getUrl().toString());
+
+ return createClassLoaderInfo(info, factory, info.getClassNames());
+ }
+
+ VFSClassLoaderInfo createImpl(ClassPathElementInfo info, ClassPathElementInfo parent)
+ {
+ VFSClassLoaderFactory factory = new VFSClassLoaderFactory(info.getName());
+ ClassLoadingMetaDataFactory metaData = ClassLoadingMetaDataFactory.getInstance();
+ for (String pkg : info.getPackageNames())
+ factory.getCapabilities().addCapability(metaData.createPackage(pkg));
+ factory.getRequirements().addRequirement(metaData.createReExportModule(parent.getName()));
+ factory.getRoots().add(info.getUrl().toString());
+
+ return createClassLoaderInfo(info, factory, info.getClassNames());
+ }
+}
Copied: projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportPackageLoaderBenchmarkTestCase.java (from rev 106993, 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/ThreeDeepVFSImportPackageLoaderBenchmarkTestCase.java (rev 0)
+++ projects/cl-benchmark/trunk/src/test/java/org/jboss/test/cl/benchmark/test/ThreeDeepVFSImportPackageLoaderBenchmarkTestCase.java 2010-07-23 09:46:37 UTC (rev 107048)
@@ -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.ClassPathElementInfo;
+import org.jboss.test.cl.benchmark.VFSClassLoaderInfo;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThreeDeepVFSImportPackageLoaderBenchmarkTestCase extends AbstractThreeDeepVFSClassLoaderBenchmark
+{
+ public ThreeDeepVFSImportPackageLoaderBenchmarkTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testLoadClassesFromOwnLoader() throws Exception
+ {
+ runBenchmark(new BenchmarkScenario<VFSClassLoaderInfo>()
+ {
+
+ public List<VFSClassLoaderInfo> createFactories(List<ClassPathElementInfo> infos)
+ {
+ List<VFSClassLoaderInfo> deploymentInfos = new ArrayList<VFSClassLoaderInfo>();
+
+ 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;
+ }
+ });
+ }
+
+ VFSClassLoaderInfo 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());
+
+ }
+
+ VFSClassLoaderInfo 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());
+ }
+
+ VFSClassLoaderInfo 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