tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader Constants.java StandardLoader.java
Date Sat, 01 Jul 2000 22:25:41 GMT
craigmcc    00/07/01 15:25:41

  Modified:    proposals/catalina/src/share/org/apache/tomcat/core
                        Constants.java StandardContext.java
               proposals/catalina/src/share/org/apache/tomcat/loader
                        Constants.java StandardLoader.java
  Log:
  Correct the order of initializing the special servlet context attributes
  that Jasper requires for specifying the web application's class loader and
  class path.  This fix restores the ability of Catalina to execute JSP
  pages that use classes in WEB-INF/classes and WEB-INF/lib which had been
  broken by recent changes in the organization of Jasper.
  
  Revision  Changes    Path
  1.5       +3 -21     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/Constants.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Constants.java	2000/06/24 01:09:00	1.4
  +++ Constants.java	2000/07/01 22:25:37	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/Constants.java,v
1.4 2000/06/24 01:09:00 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/06/24 01:09:00 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/Constants.java,v
1.5 2000/07/01 22:25:37 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/07/01 22:25:37 $
    *
    * ====================================================================
    *
  @@ -71,24 +71,6 @@
       public static final int MAJOR_VERSION = 2;
       public static final int MINOR_VERSION = 2;
       public static final String SERVER_INFO = "Apache Tomcat/X.X";
  -
  -
  -    /**
  -     * The servlet context attribute under which the class loader we use for
  -     * loading servlets is stored (object type is java.lang.ClassLoader).
  -     */
  -    public static final String CLASSLOADER_ATTR =
  -	"org.apache.tomcat.classloader";
  -
  -
  -    /**
  -     * The servlet context attribute under which the class path for our class
  -     * loader is stored (object type is java.lang.String).  The class path
  -     * consists of a list of directories and JAR/ZIP files, delimited by the
  -     * appropriate path delimiter for this platform.
  -     */
  -    public static final String CLASSPATH_ATTR =
  -	"org.apache.tomcat.jsp_classpath";
   
   
       /**
  
  
  
  1.22      +5 -55     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- StandardContext.java	2000/06/23 22:24:03	1.21
  +++ StandardContext.java	2000/07/01 22:25:39	1.22
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.21 2000/06/23 22:24:03 craigmcc Exp $
  - * $Revision: 1.21 $
  - * $Date: 2000/06/23 22:24:03 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.22 2000/07/01 22:25:39 craigmcc Exp $
  + * $Revision: 1.22 $
  + * $Date: 2000/07/01 22:25:39 $
    *
    * ====================================================================
    *
  @@ -97,7 +97,7 @@
    * requests directed to a particular servlet.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.21 $ $Date: 2000/06/23 22:24:03 $
  + * @version $Revision: 1.22 $ $Date: 2000/07/01 22:25:39 $
    */
   
   public final class StandardContext
  @@ -1480,10 +1480,6 @@
       public synchronized void setLoader(Loader loader) {
   
   	super.setLoader(loader);
  -	if (started && (loader != null)) {
  -	    setClassLoader();
  -	    setClassPath();
  -	}
   
       }
   
  @@ -1495,12 +1491,8 @@
        */
       public void start() throws LifecycleException {
   
  +	setWorkDirectory();
   	super.start();
  -	if (loader != null) {
  -	    setClassLoader();
  -	    setClassPath();
  -	    setWorkDirectory();
  -	}
   
       }
   
  @@ -1557,48 +1549,6 @@
       private void setPaused(boolean paused) {
   
   	this.paused = paused;
  -
  -    }
  -
  -
  -    /**
  -     * Set the appropriate context attribute for our class loader.
  -     */
  -    private void setClassLoader() {
  -
  -	ServletContext servletContext = getServletContext();
  -	if (servletContext == null)
  -	    return;
  -	Loader loader = getLoader();
  -	if (loader == null)
  -	    return;
  -	servletContext.setAttribute(Constants.CLASSLOADER_ATTR,
  -				    loader.getClassLoader());
  -
  -    }
  -
  -
  -    /**
  -     * Set the appropriate context attribute for our class path.
  -     */
  -    private void setClassPath() {
  -
  -	ServletContext servletContext = getServletContext();
  -	if (servletContext == null)
  -	    return;
  -	Loader loader = getLoader();
  -	if (loader == null)
  -	    return;
  -
  -	StringBuffer classpath = new StringBuffer();
  -	String repositories[] = loader.findRepositories();
  -	for (int i = 0; i < repositories.length; i++) {
  -	    if (i > 0)
  -		classpath.append(File.pathSeparator);
  -	    classpath.append(repositories[i]);
  -	}
  -	servletContext.setAttribute(Constants.CLASSPATH_ATTR,
  -				    classpath.toString());
   
       }
   
  
  
  
  1.2       +21 -3     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/Constants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Constants.java	2000/04/26 02:14:53	1.1
  +++ Constants.java	2000/07/01 22:25:40	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/Constants.java,v
1.1 2000/04/26 02:14:53 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/04/26 02:14:53 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/Constants.java,v
1.2 2000/07/01 22:25:40 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/07/01 22:25:40 $
    *
    * ====================================================================
    *
  @@ -68,6 +68,24 @@
   public class Constants {
   
       public static final String Package = "org.apache.tomcat.loader";
  +
  +    /**
  +     * The servlet context attribute under which the class loader we use for
  +     * loading servlets is stored (object type is java.lang.ClassLoader).
  +     */
  +    public static final String CLASSLOADER_ATTR =
  +	"org.apache.tomcat.classloader";
  +
  +
  +    /**
  +     * The servlet context attribute under which the class path for our class
  +     * loader is stored (object type is java.lang.String).  The class path
  +     * consists of a list of directories and JAR/ZIP files, delimited by the
  +     * appropriate path delimiter for this platform.
  +     */
  +    public static final String CLASSPATH_ATTR =
  +	"org.apache.tomcat.jsp_classpath";
  +
   
   }
   
  
  
  
  1.7       +67 -6     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java
  
  Index: StandardLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StandardLoader.java	2000/06/22 06:15:44	1.6
  +++ StandardLoader.java	2000/07/01 22:25:40	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java,v
1.6 2000/06/22 06:15:44 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/06/22 06:15:44 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java,v
1.7 2000/07/01 22:25:40 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/07/01 22:25:40 $
    *
    * ====================================================================
    *
  @@ -72,6 +72,7 @@
   import java.io.IOException;
   import java.util.Enumeration;
   import java.util.Vector;
  +import javax.servlet.ServletContext;
   import org.apache.tomcat.Container;
   import org.apache.tomcat.Context;
   import org.apache.tomcat.Lifecycle;
  @@ -97,7 +98,7 @@
    * is not present, the system class loader will be used instead.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/06/22 06:15:44 $
  + * @version $Revision: 1.7 $ $Date: 2000/07/01 22:25:40 $
    */
   
   public final class StandardLoader
  @@ -396,8 +397,10 @@
           if (debug >= 1)
   	    log(sm.getString("standardLoader.addRepository", repository));
   	repositories.addElement(repository);
  -	if (started)
  +	if (started) {
   	    classLoader.addRepository(repository);
  +	    setClassPath();
  +	}
   
       }
   
  @@ -451,8 +454,10 @@
           if (debug >= 1)
   	    log(sm.getString("standardLoader.removeRepository", repository));
   	repositories.removeElement(repository);
  -	if (started)
  +	if (started) {
   	    classLoader.removeRepository(repository);
  +	    setClassPath();
  +	}
   
       }
   
  @@ -527,6 +532,10 @@
   	    throw new LifecycleException("start: ", t);
   	}
   
  +	// Set up context attributes if appropriate
  +	setClassLoader();
  +	setClassPath();
  +
   	// Start our background thread if we are reloadable
   	if (reloadable) {
   	    log(sm.getString("standardLoader.reloading"));
  @@ -561,6 +570,14 @@
   	if (reloadable)
   	    threadStop();
   
  +	// Remove context attributes as appropriate
  +	if (container instanceof Context) {
  +	    ServletContext servletContext =
  +		((Context) container).getServletContext();
  +	    servletContext.removeAttribute(Constants.CLASSLOADER_ATTR);
  +	    servletContext.removeAttribute(Constants.CLASSPATH_ATTR);
  +	}
  +
   	// Throw away our current class loader
   	if (classLoader instanceof Lifecycle)
   	    ((Lifecycle) classLoader).stop();
  @@ -659,6 +676,50 @@
   
   	ContextNotifier notifier = new ContextNotifier((Context) container);
   	(new Thread(notifier)).start();
  +
  +    }
  +
  +
  +    /**
  +     * Set the appropriate context attribute for our class loader.  This
  +     * is required only because Jasper depends on it.
  +     */
  +    private void setClassLoader() {
  +
  +	if (!(container instanceof Context))
  +	    return;
  +	ServletContext servletContext =
  +	    ((Context) container).getServletContext();
  +	if (servletContext == null)
  +	    return;
  +	servletContext.setAttribute(Constants.CLASSLOADER_ATTR,
  +				    getClassLoader());
  +
  +    }
  +
  +
  +    /**
  +     * Set the appropriate context attribute for our class path.  This
  +     * is required only because Jasper depends on it.
  +     */
  +    private void setClassPath() {
  +
  +	if (!(container instanceof Context))
  +	    return;
  +	ServletContext servletContext =
  +	    ((Context) container).getServletContext();
  +	if (servletContext == null)
  +	    return;
  +
  +	StringBuffer classpath = new StringBuffer();
  +	String repositories[] = findRepositories();
  +	for (int i = 0; i < repositories.length; i++) {
  +	    if (i > 0)
  +		classpath.append(File.pathSeparator);
  +	    classpath.append(repositories[i]);
  +	}
  +	servletContext.setAttribute(Constants.CLASSPATH_ATTR,
  +				    classpath.toString());
   
       }
   
  
  
  

Mime
View raw message