cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@locus.apache.org
Subject cvs commit: xml-cocoon/webapp/WEB-INF web.xml
Date Mon, 18 Dec 2000 15:01:30 GMT
bloritsch    00/12/18 07:01:27

  Modified:    .        Tag: xml-cocoon2 changes.xml
               src/org/apache/cocoon/components/classloader Tag:
                        xml-cocoon2 RepositoryClassLoader.java
               src/org/apache/cocoon/components/language/markup/xsp/java
                        Tag: xml-cocoon2 esql.xsl
               src/org/apache/cocoon/components/language/programming/java
                        Tag: xml-cocoon2 Javac.java
               src/org/apache/cocoon/servlet Tag: xml-cocoon2
                        CocoonServlet.java
               src/org/apache/cocoon/util Tag: xml-cocoon2 ClassUtils.java
                        NetUtils.java
               webapp/WEB-INF Tag: xml-cocoon2 web.xml
  Log:
  More ClassLoader updates (mostly logging)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.9.2.16  +5 -1      xml-cocoon/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/changes.xml,v
  retrieving revision 1.9.2.15
  retrieving revision 1.9.2.16
  diff -u -r1.9.2.15 -r1.9.2.16
  --- changes.xml	2000/11/30 21:40:15	1.9.2.15
  +++ changes.xml	2000/12/18 15:00:51	1.9.2.16
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: changes.xml,v 1.9.2.15 2000/11/30 21:40:15 bloritsch Exp $
  +  $Id: changes.xml,v 1.9.2.16 2000/12/18 15:00:51 bloritsch Exp $
   -->
   
   <changes title="History of Changes">
  @@ -21,6 +21,10 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="BL" type="update">
  +    Clean up a lot of classloader issues.  RepositoryClassLoader is quicker and
  +    more stable accross installations.  ClassUtils takes care of getting resources.
  +  </action>
     <action dev="BL" type="update">
       Updated avalonapi to implement hierarchical logging, and added many more
       log entries to get a handle on where the problems lay.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.15  +6 -2      xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/RepositoryClassLoader.java
  
  Index: RepositoryClassLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/classloader/Attic/RepositoryClassLoader.java,v
  retrieving revision 1.1.2.14
  retrieving revision 1.1.2.15
  diff -u -r1.1.2.14 -r1.1.2.15
  --- RepositoryClassLoader.java	2000/12/15 17:57:54	1.1.2.14
  +++ RepositoryClassLoader.java	2000/12/18 15:00:59	1.1.2.15
  @@ -26,10 +26,14 @@
   import org.apache.log.LogKit;
   
   /**
  - * A class loader with a growable list of path search directories
  + * A class loader with a growable list of path search directories.
  + * BL: Changed to extend URLClassLoader for both maintenance and
  + *     compatibility reasons.  It doesn't hurt that it runs quicker
  + *     now as well.
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.14 $ $Date: 2000/12/15 17:57:54 $
  + * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  + * @version CVS $Revision: 1.1.2.15 $ $Date: 2000/12/18 15:00:59 $
    */
   class RepositoryClassLoader extends URLClassLoader {
     /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.9   +2 -2      xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/esql.xsl
  
  Index: esql.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/esql.xsl,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- esql.xsl	2000/12/08 20:39:11	1.1.2.8
  +++ esql.xsl	2000/12/18 15:01:03	1.1.2.9
  @@ -1,5 +1,5 @@
   <?xml version="1.0"?>
  -<!-- $Id: esql.xsl,v 1.1.2.8 2000/12/08 20:39:11 bloritsch Exp $-->
  +<!-- $Id: esql.xsl,v 1.1.2.9 2000/12/18 15:01:03 bloritsch Exp $-->
   <!--
   
    ============================================================================
  @@ -261,7 +261,7 @@
             <!-- FIXME - need to do avalon pooling here maybe? -->
            </xsl:when>
            <xsl:otherwise>
  -          Class.forName(String.valueOf(<xsl:copy-of select="$driver"/>)).newInstance();
  +          ClassUtils.newInstance(String.valueOf(<xsl:copy-of select="$driver"/>));
             <xsl:choose>
              <xsl:when test="esql:username">
               _esql_session.connection = DriverManager.getConnection(
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.8   +6 -5      xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Javac.java
  
  Index: Javac.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/programming/java/Attic/Javac.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- Javac.java	2000/12/08 20:39:17	1.1.2.7
  +++ Javac.java	2000/12/18 15:01:09	1.1.2.8
  @@ -11,12 +11,13 @@
   import java.io.*;
   import java.util.*;
   import org.apache.cocoon.components.language.programming.*;
  +import org.apache.cocoon.util.ClassUtils;
   
   /**
    * This class wraps the Sun's Javac Compiler.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.1.2.7 $ $Date: 2000/12/08 20:39:17 $
  + * @version $Revision: 1.1.2.8 $ $Date: 2000/12/18 15:01:09 $
    * @since 2.0
    */
   
  @@ -31,14 +32,14 @@
   
       // Use reflection to be able to build on all JDKs
       try {
  -        Class.forName(MODERN_CLASS);
  +        ClassUtils.loadClass(MODERN_CLASS);
           modern = true;
  -    } catch (ClassNotFoundException e) {
  +    } catch (Exception e) {
           log.warn("Javac()", e);
           try {
  -            Class.forName(CLASSIC_CLASS);
  +            ClassUtils.loadClass(CLASSIC_CLASS);
               modern = false;
  -        } catch (ClassNotFoundException ex) {
  +        } catch (Exception ex) {
               log.warn("No compiler found in your classpath. Make sure you added 'tools.jar'",
ex);
               throw new RuntimeException("No compiler found in your classpath. Make sure
you added 'tools.jar'");
           }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.39  +6 -3      xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
  retrieving revision 1.1.4.38
  retrieving revision 1.1.4.39
  diff -u -r1.1.4.38 -r1.1.4.39
  --- CocoonServlet.java	2000/12/08 20:40:25	1.1.4.38
  +++ CocoonServlet.java	2000/12/18 15:01:15	1.1.4.39
  @@ -36,6 +36,7 @@
   import org.apache.cocoon.Notifier;
   import org.apache.cocoon.Notification;
   import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.util.ClassUtils;
   
   import org.apache.log.Logger;
   import org.apache.log.LogKit;
  @@ -52,7 +53,7 @@
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.4.38 $ $Date: 2000/12/08 20:40:25 $
  + * @version CVS $Revision: 1.1.4.39 $ $Date: 2000/12/18 15:01:15 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -103,6 +104,8 @@
   
           this.root = this.context.getRealPath("/");
   
  +        ClassUtils.setClassLoader(this.getClass().getClassLoader());
  +
           this.createCocoon();
       }
   
  @@ -214,7 +217,7 @@
           log.info("Using configuration file: " + configFileName);
   
           try {
  -            this.configFile = context.getResource(configFileName);
  +            this.configFile = this.context.getResource(configFileName);
           } catch (Exception mue) {
               log.error("Servlet initialization argument 'configurations' not found at "
+ configFileName, mue);
               throw new ServletException("Servlet initialization argument 'configurations'
not found at " + configFileName);
  @@ -245,7 +248,7 @@
                   final String fqcn = fqcnTokenizer.nextToken().trim();
   
                   try {
  -                    Class.forName(fqcn);
  +                    ClassUtils.loadClass(fqcn);
                   } catch (Exception e) {
                       log.error("Could not force-load class: " + fqcn, e);
                       throw new ServletException("Could not force-load the required class:
" +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +51 -11    xml-cocoon/src/org/apache/cocoon/util/Attic/ClassUtils.java
  
  Index: ClassUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/ClassUtils.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- ClassUtils.java	2000/10/08 21:10:51	1.1.2.5
  +++ ClassUtils.java	2000/12/18 15:01:20	1.1.2.6
  @@ -5,24 +5,32 @@
    * version 1.1, a copy of which has been included  with this distribution in *
    * the LICENSE file.                                                         *
    *****************************************************************************/
  - 
  +
   package org.apache.cocoon.util;
   
   import java.io.File;
   import java.net.URL;
  +import java.net.MalformedURLException;
   
   import java.io.IOException;
   
  +import javax.servlet.ServletContext;
  +
   /**
    * A collection of class management utility methods.
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/10/08 21:10:51 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/12/18 15:01:20 $
    */
   public class ClassUtils {
  -    
  +
       /**
  +     * Reference for global ClassLoader that Cocoon uses throughout.
  +     */
  +    private static ClassLoader loader = null;
  +
  +    /**
        * Create a new instance given a class name
        *
        * @param className A class name
  @@ -30,30 +38,62 @@
        * @exception Exception If an instantiation error occurs
        */
       public static Object newInstance(String className) throws Exception {
  -        return loadClass(className).newInstance();
  +        return ClassUtils.loadClass(className).newInstance();
       }
   
       /**
  -     * Load a class given its name
  +     * Load a class given its name.
  +     * BL: We wan't to use a known ClassLoader--hopefully the heirarchy
  +     *     is set correctly.
        *
        * @param className A class name
        * @return The class pointed to by <code>className</code>
        * @exception Exception If a loading error occurs
        */
       public static Class loadClass(String className) throws Exception {
  -        // return getClassLoader().loadClass(className);
           return Class.forName(className);
       }
   
  +    /**
  +     * Return a resource URL.
  +     * BL: if this is command line operation, the classloading issues
  +     *     are more sane.  During servlet execution, we explicitly set
  +     *     the ClassLoader.
  +     *
  +     * @return The context classloader.
  +     * @exception Exception If a loading error occurs
  +     */
  +    public static URL getResource(String resource) throws MalformedURLException {
  +        return ClassUtils.getClassLoader().getResource(resource);
  +    }
  +
       /**
  -     * Return the context classloader
  +     * Return the context classloader.
  +     * BL: if this is command line operation, the classloading issues
  +     *     are more sane.  During servlet execution, we explicitly set
  +     *     the ClassLoader.
        *
        * @return The context classloader.
        * @exception Exception If a loading error occurs
        */
       public static ClassLoader getClassLoader() {
  -        // return Thread.currentThread().getContextClassLoader();
  -        return ClassUtils.class.getClassLoader();
  +        if (ClassUtils.loader == null) {
  +            setClassLoader(ClassUtils.class.getClassLoader());
  +        }
  +
  +        return loader;
  +    }
  +
  +    /**
  +     * Set the context classloader
  +     * BL: if this is command line operation, the classloading issues
  +     *     are more sane.  During servlet execution, we explicitly set
  +     *     the ClassLoader.
  +     */
  +    public static void setClassLoader(ClassLoader loader) {
  +        if (ClassUtils.loader == null) {
  +            ClassUtils.loader = loader;
  +        }
       }
   
       /**
  @@ -62,8 +102,8 @@
        * @return true if class implements given interface.
        */
       public static boolean implementsInterface(String className, String iface) throws Exception
{
  -        Class class1 = loadClass (className);
  -        Class class2 = loadClass (iface);
  +        Class class1 = ClassUtils.loadClass (className);
  +        Class class2 = ClassUtils.loadClass (iface);
           if (class2.isAssignableFrom (class1)) {
               return true;
           }
  
  
  
  1.1.2.3   +2 -2      xml-cocoon/src/org/apache/cocoon/util/Attic/NetUtils.java
  
  Index: NetUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/NetUtils.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- NetUtils.java	2000/10/06 21:25:32	1.1.2.2
  +++ NetUtils.java	2000/12/18 15:01:21	1.1.2.3
  @@ -18,7 +18,7 @@
    * utility methods
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/10/06 21:25:32 $
  + * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/12/18 15:01:21 $
    */
   
   public class NetUtils {
  @@ -36,7 +36,7 @@
           if (location.indexOf("://") < 0) {
               return (new File(location)).toURL();
           } else if (location.startsWith("resource://")) {
  -            URL u = ClassUtils.getClassLoader().getResource(location.substring("resource://".length()));
  +            URL u = ClassUtils.getResource(location.substring("resource://".length()));
               if (u != null) return u;
               else throw new RuntimeException(location + " could not be found. (possible
classloader problem)");
           } else {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.7   +1 -1      xml-cocoon/webapp/WEB-INF/Attic/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/webapp/WEB-INF/Attic/web.xml,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- web.xml	2000/12/12 14:49:03	1.1.2.6
  +++ web.xml	2000/12/18 15:01:25	1.1.2.7
  @@ -15,7 +15,7 @@
     <servlet-name>Cocoon2</servlet-name>
     <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
     <init-param>
  -   <param-name>configurations</param-name>
  +  <param-name>configurations</param-name>
      <!-- CHANGE PATH BELOW -->
      <param-value>/cocoon.xconf</param-value>
     </init-param>
  
  
  

Mime
View raw message