tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costin Manolache <cos...@eng.sun.com>
Subject Re: [PATCH] Parent for AdaptiveClassLoader
Date Mon, 05 Jun 2000 15:21:26 GMT
Thanks Ken, I'll check this in as soon as I get a better connection.


Costin


> Here's the patch for adding a Parent class loader, a la JDK 1.2 to ACL. I've
> implemented it using a new private var so JDK 1.1 will be okay.
>
> Wasn't sure of the format for the diff - this one's diff -c  -- also not sure if
> this is the latest version - haven't had time to check (sorry).
>
> Ken.
>
> *** AdaptiveClassLoader.java.orig        Tue Apr 18 15:56:20 2000
> --- AdaptiveClassLoader.java.parented    Mon Jun  5 11:02:16 2000
> **************
> **** 149,154 ****
> --- 149,162 ----
>       private Vector repository;
>
>       /**
> +      * A parent class loader for delegation of finding a class definition.
> +      * JDK 1.2 contains parent class loaders as part of java.lang.ClassLoader,
> the parent
> +      * being passed to a constructor, and retreived with getParent() method.
> For JDK 1.1
> +      * compatibility, we'll duplicate the 1.2 private member var.
> +      */
> +     private ClassLoader parent;
> +
> +     /**
>        * Private class used to maintain information about the classes that
>        * we loaded.
>        */
> **************
> **** 195,200 ****
> --- 203,230 ----
>       public AdaptiveClassLoader(Vector classRepository)
>           throws IllegalArgumentException
>       {
> +         this(classRepository, null);
> +     }
> +
> +     /**
> +      * Creates a new class loader that will load classes from specified
> +      * class repositories, delegating first to the passed parent for
> definitions.
> +      *
> +      * @param classRepository An set of File classes indicating
> +      *        directories and/or zip/jar files. It may be empty when
> +      *        only system classes are loaded.
> +      * @param theParent A containing class loader for initial delegation of
> class
> +      *        definition serach.
> +      * @throw java.lang.IllegalArgumentException if the objects contained
> +      *        in the vector are not a file instance or the file is not
> +      *        a valid directory or a zip/jar file.
> +      */
> +
> +     public AdaptiveClassLoader(Vector classRepository, ClassLoader theParent)
> +         throws IllegalArgumentException
> +     {
> +         this.parent = theParent;
> +
>           // Create the cache of loaded classes
>           cache = new Hashtable();
>
> **************
> **** 407,412 ****
> --- 437,456 ----
>               c = null;
>           }
>
> +         if (parent != null) {();oaded
> +             try {
> +                 c = parent.loadClass(name);
> +                 if (c != null) {
> +                     if (resolve) resolveClass(c);
> +                     return c;
> +                 }
> +             } catch (ClassNotFoundException e) {
> +                 c = null;
> +             } catch (Exception e) {
> +                 c = null;
> +             }
> +         }
> +
>           // Try to load it from each repository
>           Enumeration repEnum = repository.elements();
>
> **************
> **** 756,759 ****
>           // Not found
>           return null;
>       }
> ! }
> --- 800,803 ----          // Not found
>           return null;
>       }
> ! }
>
> This communication is for informational purposes only.  It is not intended as
> an offer or solicitation for the purchase or sale of any financial instrument
> or as an official confirmation of any transaction. All market prices, data
> and other information are not warranted as to completeness or accuracy and
> are subject to change without notice. Any comments or statements made herein
> do not necessarily reflect those of J.P. Morgan & Co. Incorporated, its
> subsidiaries and affiliates.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message