commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kohs...@apache.org
Subject svn commit: r232416 - in /jakarta/commons/sandbox/javaflow/trunk/src: java/org/apache/commons/javaflow/ test/org/apache/commons/javaflow/
Date Sat, 13 Aug 2005 04:45:55 GMT
Author: kohsuke
Date: Fri Aug 12 21:45:47 2005
New Revision: 232416

URL: http://svn.apache.org/viewcvs?rev=232416&view=rev
Log:
moved the original ContinuationClassLoader as a TestClassLoader into the test module.

Added:
    jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/TestClassLoader.java
      - copied, changed from r232414, jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationClassLoader.java
Removed:
    jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationClassLoader.java
Modified:
    jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationURLClassLoader.java
    jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/AbstractClassLoaderTestCase.java

Modified: jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationURLClassLoader.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationURLClassLoader.java?rev=232416&r1=232415&r2=232416&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationURLClassLoader.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationURLClassLoader.java
Fri Aug 12 21:45:47 2005
@@ -21,8 +21,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
-import java.net.URL;
 import java.net.URLClassLoader;
+import java.net.URL;
 import java.security.ProtectionDomain;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -34,6 +34,7 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import org.apache.commons.javaflow.bytecode.transformation.ClassTransformer;
+import org.apache.commons.javaflow.bytecode.transformation.bcel.BcelClassTransformer;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -42,7 +43,7 @@
  *
  * <p>
  * This <tt>ClassLoader</tt> works like an <tt>URLClassLoader</tt>
- * in the sense that it locates class files from specified {@link URL}s.
+ * in the sense that it locates class files from specified {@link File}s.
  * But instead of simply loading classes into the VM, this class loader
  * performs the bytecode instrumentation necessary for javaflow.
  *
@@ -159,7 +160,7 @@
 
     /**
      * The components of the classpath that the classloader searches
-     * for classes.
+     * for classes. {@link List} of {@link File}s.
      */
     private List pathComponents  = new ArrayList();
 
@@ -203,7 +204,24 @@
 
 
     /**
-     * Creates a classloader for the given project using the classpath given.
+     * Creates a classloader  using the classpath given.
+     *
+     * @param parent The parent classloader to which unsatisfied loading
+     *               attempts are delegated. May be <code>null</code>,
+     *               in which case the classloader which loaded this
+     *               class is used as the parent.
+     * @param classpath
+     *      a {@link Collection} of {@link File}s.
+     *      the classpath to use to load the classes.
+     *      May be <code>null</code>, in which case no path
+     *      elements are set up to start with.
+     */
+    public ContinuationURLClassLoader(ClassLoader parent, Collection classpath) {
+        this(parent,new BcelClassTransformer(),classpath);
+    }
+
+    /**
+     * Creates a classloader  using the classpath given.
      *
      * @param parent The parent classloader to which unsatisfied loading
      *               attempts are delegated. May be <code>null</code>,
@@ -257,7 +275,7 @@
     /**
      * Add a file to the path
      *
-     * @param pathComponent the file which is to be added to the path for
+     * @param pathComponent the URL which is to be added to the path for
      *                      this class loader
      */
     protected synchronized void addPathFile(File pathComponent) {
@@ -265,27 +283,6 @@
     }
 
     /**
-     * Returns the classpath this classloader will consult.
-     *
-     * @return the classpath used for this classloader, with elements
-     *         separated by the path separator for the system.
-     */
-    public synchronized String getClasspath() {
-        StringBuffer sb = new StringBuffer();
-        boolean firstPass = true;
-        for (Iterator itr = pathComponents.iterator(); itr.hasNext();) {
-            File file = (File) itr.next();
-            if (!firstPass) {
-                sb.append(System.getProperty("path.separator"));
-            } else {
-                firstPass = false;
-            }
-            sb.append(file.getAbsolutePath());
-        }
-        return sb.toString();
-    }
-
-    /**
      * Sets whether this classloader should run in isolated mode. In
      * isolated mode, classes not found on the given classpath will
      * not be referred to the parent class loader but will cause a
@@ -817,11 +814,11 @@
     }
 
     /**
-     * Indicate if the given file is in this loader's path
+     * Indicate if the given URL is in this loader's path
      *
-     * @param component the file which is to be checked
+     * @param component the URL which is to be checked
      *
-     * @return true if the file is in the class path
+     * @return true if the URL is in the class path
      */
     protected synchronized boolean isInPath(File component) {
         for (Iterator itr = pathComponents.iterator(); itr.hasNext();) {

Modified: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/AbstractClassLoaderTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/AbstractClassLoaderTestCase.java?rev=232416&r1=232415&r2=232416&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/AbstractClassLoaderTestCase.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/AbstractClassLoaderTestCase.java
Fri Aug 12 21:45:47 2005
@@ -17,6 +17,7 @@
 
 import java.lang.reflect.Method;
 import java.util.Map;
+import java.net.URL;
 
 import junit.framework.TestCase;
 
@@ -35,7 +36,7 @@
     }
           
     protected void call(final String methodName) throws Exception {
-        final ClassLoader cl = new ContinuationClassLoader(getClass().getClassLoader());
+        final TestClassLoader cl = new TestClassLoader(getClass().getClassLoader());
         final Class clazz = cl.loadClass(clazzName);
         final Object instance = clazz.newInstance();
         assertNotNull(clazz);
@@ -44,10 +45,10 @@
         final Map methods = ReflectionUtils.discoverMethods(clazz);
         assertNotNull(methods);
         assertTrue(methods.size() > 0);
-        
+
         Thread.currentThread().setContextClassLoader(cl);
-        
-        final Method method = (Method) methods.get(methodName);        
+
+        final Method method = (Method) methods.get(methodName);
         method.invoke(instance, new Object[] { });
     }
     

Copied: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/TestClassLoader.java
(from r232414, jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationClassLoader.java)
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/TestClassLoader.java?p2=jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/TestClassLoader.java&p1=jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationClassLoader.java&r1=232414&r2=232416&rev=232416&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ContinuationClassLoader.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/TestClassLoader.java
Fri Aug 12 21:45:47 2005
@@ -40,11 +40,10 @@
  * confusing runtime errors.
  *
  * @author tcurdt
- * @see ContinuationURLClassLoader
  */
-public final class ContinuationClassLoader extends ClassLoader {
+public final class TestClassLoader extends ClassLoader {
     
-    private final static Log log = LogFactory.getLog(ContinuationClassLoader.class);
+    private final static Log log = LogFactory.getLog(TestClassLoader.class);
     
     private ClassTransformer transformer = new BcelClassTransformer();
     
@@ -60,8 +59,15 @@
     private String[] includeInRewriting = {
         "org.apache.commons.javaflow.testcode"
     };
-    
-    public ContinuationClassLoader(ClassLoader parent) {
+
+    /**
+     * Creates a class loader.
+     *
+     * @param parent
+     *      The parent class loader. Can be null, in which case the
+     *      bootstrap class loader is used as the parent class loader.
+     */
+    public TestClassLoader(ClassLoader parent) {
         super(parent);
         //Repository.setRepository(new ClassLoaderRepository(parent));
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message