You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/05/12 02:47:27 UTC
cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets SnoopAllServlet.java
craigmcc 00/05/11 17:47:27
Modified: proposals/catalina build.xml
proposals/catalina/src/bin catalina.sh
proposals/catalina/src/conf server.xml
proposals/catalina/src/share/org/apache/tomcat Loader.java
proposals/catalina/src/share/org/apache/tomcat/core
ApplicationContext.java Constants.java
LocalStrings.properties StandardContext.java
StandardWrapper.java
proposals/catalina/src/share/org/apache/tomcat/loader
FileClassLoader.java LocalStrings.properties
Reloader.java StandardLoader.java
proposals/catalina/src/share/org/apache/tomcat/resources
StandardResources.java
proposals/catalina/src/share/org/apache/tomcat/servlets
SnoopAllServlet.java
Log:
Complete the implementation of the StandardLoader component (and a new
class loader named FileClassLoader that supports dynamic changes to the
repository). Autoreload is not yet implemented, but it will be added
shortly (via a background thread the way it was done in Apache JServ).
In addition, several servlet context attributes are now created to provide
information to the Tomcat JSP servlet (as opposed to having to provide
this information via servlet initialization attributes).
Revision Changes Path
1.13 +4 -1 jakarta-tomcat/proposals/catalina/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/build.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- build.xml 2000/05/07 01:43:41 1.12
+++ build.xml 2000/05/12 00:47:22 1.13
@@ -35,8 +35,11 @@
<!-- Compile the server components -->
<target name="main" depends="prepare,static">
<javac srcdir="src/share" destdir="${catalina.build}/classes"
- classpath="${servlet.jar}" deprecation="off" debug="on"
+ classpath="${servlet.jar}" deprecation="off" debug="on" optimize="off"
excludes="**/CVS/**"/>
+ <copydir src="src/share" dest="${catalina.build}/classes">
+ <include name="**/*.properties"/>
+ </copydir>
</target>
<!-- Copy the web applications from Tomcat -->
1.6 +2 -2 jakarta-tomcat/proposals/catalina/src/bin/catalina.sh
Index: catalina.sh
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/bin/catalina.sh,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- catalina.sh 2000/05/07 01:43:41 1.5
+++ catalina.sh 2000/05/12 00:47:22 1.6
@@ -22,7 +22,7 @@
# If not present, the directory "%CATALINA_HOME%\..\tomcat"
# is assumed.
#
-# $Id: catalina.sh,v 1.5 2000/05/07 01:43:41 craigmcc Exp $
+# $Id: catalina.sh,v 1.6 2000/05/12 00:47:22 craigmcc Exp $
# -----------------------------------------------------------------------------
@@ -34,7 +34,7 @@
fi
if [ "$CATALINA_HOME" = "" ] ; then
- CATALINA_HOME=.
+ CATALINA_HOME=`pwd`
fi
if [ "$CATALINA_OPTS" = "" ] ; then
1.22 +1 -3 jakarta-tomcat/proposals/catalina/src/conf/server.xml
Index: server.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/conf/server.xml,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- server.xml 2000/05/09 22:40:17 1.21
+++ server.xml 2000/05/12 00:47:23 1.22
@@ -72,10 +72,8 @@
<Context path="/examples" docBase="webapps/examples" debug="0">
<Listener className="org.apache.tomcat.startup.ContextConfig"
debug="0"/>
- <Loader className="org.apache.tomcat.loader.StandardLoader"
- debug="3"/>
<Manager className="org.apache.tomcat.session.StandardManager"
- checkInterval="15" maxActiveSessions="200"
+ checkInterval="15" maxActiveSessions="1000"
pathname="sessions/localhost_examples.sessions"/>
</Context>
1.3 +27 -4 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Loader.java
Index: Loader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Loader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Loader.java 2000/01/29 07:46:32 1.2
+++ Loader.java 2000/05/12 00:47:23 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Loader.java,v 1.2 2000/01/29 07:46:32 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/01/29 07:46:32 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Loader.java,v 1.3 2000/05/12 00:47:23 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/05/12 00:47:23 $
*
* ====================================================================
*
@@ -76,7 +76,7 @@
* repository.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/01/29 07:46:32 $
+ * @version $Revision: 1.3 $ $Date: 2000/05/12 00:47:23 $
*/
public interface Loader {
@@ -125,6 +125,21 @@
/**
+ * Add a new repository to the set of repositories for this class loader.
+ *
+ * @param repository Repository to be added
+ */
+ public void addRepository(String repository);
+
+
+ /**
+ * Return the set of repositories defined for this class loader.
+ * If none are defined, a zero-length array is returned.
+ */
+ public String[] findRepositories();
+
+
+ /**
* Has the internal repository associated with this Loader been modified,
* such that the loaded classes should be reloaded?
*/
@@ -144,6 +159,14 @@
* @param listener The listener to remove
*/
public void removePropertyChangeListener(PropertyChangeListener listener);
+
+
+ /**
+ * Remove a repository from the set of repositories for this loader.
+ *
+ * @param repository Repository to be removed
+ */
+ public void removeRepository(String repository);
}
1.8 +5 -5 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationContext.java
Index: ApplicationContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationContext.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ApplicationContext.java 2000/05/05 05:59:08 1.7
+++ ApplicationContext.java 2000/05/12 00:47:24 1.8
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationContext.java,v 1.7 2000/05/05 05:59:08 craigmcc Exp $
- * $Revision: 1.7 $
- * $Date: 2000/05/05 05:59:08 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationContext.java,v 1.8 2000/05/12 00:47:24 craigmcc Exp $
+ * $Revision: 1.8 $
+ * $Date: 2000/05/12 00:47:24 $
*
* ====================================================================
*
@@ -91,7 +91,7 @@
* associated with each instance of <code>StandardContext</code>.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.7 $ $Date: 2000/05/05 05:59:08 $
+ * @version $Revision: 1.8 $ $Date: 2000/05/12 00:47:24 $
*/
final class ApplicationContext
@@ -137,7 +137,7 @@
StringManager.getManager(Constants.Package);
- // --------------------------------------------------------- Public Methods
+ // ------------------------------------------------- ServletContext Methods
/**
1.3 +29 -3 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Constants.java 2000/01/24 08:31:31 1.2
+++ Constants.java 2000/05/12 00:47:24 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/Constants.java,v 1.2 2000/01/24 08:31:31 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/01/24 08:31:31 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/Constants.java,v 1.3 2000/05/12 00:47:24 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/05/12 00:47:24 $
*
* ====================================================================
*
@@ -71,6 +71,32 @@
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";
+
+
+ /**
+ * The servlet context attribute under which a temporary working directory
+ * is stored (object type is java.io.File).
+ */
+ public static final String WORKDIR_ATTR =
+ "javax.servlet.context.tempdir";
}
1.12 +2 -0 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/LocalStrings.properties,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- LocalStrings.properties 2000/05/01 01:53:54 1.11
+++ LocalStrings.properties 2000/05/12 00:47:24 1.12
@@ -32,6 +32,8 @@
standardServer.stop.notStarted=This server has not yet been started
standardWrapper.loadError=Exception loading servlet of class {0}
standardWrapper.noChild=Wrapper cannot have a child Container
+standardWrapper.noClass=Wrapper cannot load class {0}
standardWrapper.noLoader=Wrapper cannot find the Loader to use
standardWrapper.noServlet=No servlet class has been configured
standardWrapper.servletException=Servlet execution threw exception
+standardWrapper.servletInit=Servlet init() threw exception
1.18 +149 -5 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- StandardContext.java 2000/05/05 05:59:08 1.17
+++ StandardContext.java 2000/05/12 00:47:24 1.18
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v 1.17 2000/05/05 05:59:08 craigmcc Exp $
- * $Revision: 1.17 $
- * $Date: 2000/05/05 05:59:08 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v 1.18 2000/05/12 00:47:24 craigmcc Exp $
+ * $Revision: 1.18 $
+ * $Date: 2000/05/12 00:47:24 $
*
* ====================================================================
*
@@ -65,6 +65,7 @@
package org.apache.tomcat.core;
+import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -76,6 +77,8 @@
import org.apache.tomcat.Container;
import org.apache.tomcat.Context;
import org.apache.tomcat.HttpRequest;
+import org.apache.tomcat.LifecycleException;
+import org.apache.tomcat.Loader;
import org.apache.tomcat.Request;
import org.apache.tomcat.Response;
import org.apache.tomcat.Wrapper;
@@ -92,7 +95,7 @@
* requests directed to a particular servlet.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.17 $ $Date: 2000/05/05 05:59:08 $
+ * @version $Revision: 1.18 $ $Date: 2000/05/12 00:47:24 $
*/
public final class StandardContext
@@ -238,6 +241,13 @@
/**
+ * The pathname to the work directory for this context (relative to
+ * the server's home if not absolute).
+ */
+ private String workDir = null;
+
+
+ /**
* Java class name of the Wrapper class implementation we use.
*/
private String wrapperClass = "org.apache.tomcat.core.StandardWrapper";
@@ -367,7 +377,7 @@
/**
* Return the servlet context for which this Context is a facade.
*/
- public ServletContext getServletContext() {
+ public synchronized ServletContext getServletContext() {
if (context == null)
context = new ApplicationContext(this);
@@ -405,6 +415,31 @@
/**
+ * Return the work directory for this Context.
+ */
+ public String getWorkDir() {
+
+ return (this.workDir);
+
+ }
+
+
+ /**
+ * Set the work directory for this Context.
+ *
+ * @param workDir The new work directory
+ */
+ public void setWorkDir(String workDir) {
+
+ this.workDir = workDir;
+
+ if (started)
+ setWorkDirectory();
+
+ }
+
+
+ /**
* Return the Java class name of the Wrapper implementation used
* for servlets registered in this Context.
*/
@@ -1392,6 +1427,39 @@
/**
+ * Set the Loader with which this Context is associated.
+ *
+ * @param loader The newly associated loader
+ */
+ public synchronized void setLoader(Loader loader) {
+
+ super.setLoader(loader);
+ if (started && (loader != null)) {
+ setClassLoader();
+ setClassPath();
+ }
+
+ }
+
+
+ /**
+ * Start this Context component.
+ *
+ * @param LifecycleException if a startup error occurs
+ */
+ public void start() throws LifecycleException {
+
+ super.start();
+ if (loader != null) {
+ setClassLoader();
+ setClassPath();
+ setWorkDirectory();
+ }
+
+ }
+
+
+ /**
* Return a String representation of this component.
*/
public String toString() {
@@ -1405,6 +1473,82 @@
sb.append(getName());
sb.append("]");
return (sb.toString());
+
+ }
+
+
+ // -------------------------------------------------------- Private Methods
+
+
+ /**
+ * 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());
+
+ }
+
+
+ /**
+ * Set the appropriate context attribute for our work directory.
+ */
+ private void setWorkDirectory() {
+
+ // Acquire (or calculate) the work directory path
+ String workDir = getWorkDir();
+ if (workDir == null) {
+ String temp = getPath();
+ if (temp.startsWith("/"))
+ temp = temp.substring(1);
+ temp = temp.replace('/', '_');
+ temp = temp.replace('\\', '_');
+ if (temp.length() < 1)
+ temp = "_";
+ workDir = "work" + File.separator + temp;
+ setWorkDir(workDir);
+ }
+
+ // Create this directory if necessary
+ File dir = new File(workDir);
+ if (!dir.isAbsolute())
+ dir = new File(System.getProperty("catalina.home"), workDir);
+ dir.mkdirs();
+
+ // Set the appropriate servlet context attribute
+ getServletContext().setAttribute(Constants.WORKDIR_ATTR, dir);
}
1.10 +27 -9 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapper.java
Index: StandardWrapper.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapper.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StandardWrapper.java 2000/05/03 22:58:24 1.9
+++ StandardWrapper.java 2000/05/12 00:47:24 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapper.java,v 1.9 2000/05/03 22:58:24 craigmcc Exp $
- * $Revision: 1.9 $
- * $Date: 2000/05/03 22:58:24 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapper.java,v 1.10 2000/05/12 00:47:24 craigmcc Exp $
+ * $Revision: 1.10 $
+ * $Date: 2000/05/12 00:47:24 $
*
* ====================================================================
*
@@ -96,7 +96,7 @@
* make them efficient are counter-productive.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.9 $ $Date: 2000/05/03 22:58:24 $
+ * @version $Revision: 1.10 $ $Date: 2000/05/12 00:47:24 $
*/
public final class StandardWrapper
@@ -416,8 +416,6 @@
try {
load();
} catch (Exception e) {
- log(sm.getString("standardWrapper.loadError", servletClass),
- e);
return (null);
}
}
@@ -551,24 +549,44 @@
// Complain if no servlet class has been specified
// FIXME - support for JSP file servlets!!!
- if (servletClass == null)
+ if (servletClass == null) {
+ log(sm.getString("standardWrapper.noServlet"));
throw new ServletException
(sm.getString("standardWrapper.noServlet"));
+ }
// Acquire an instance of the class loader to be used
Loader loader = ((Context) getParent()).getLoader();
- if (loader == null)
+ if (loader == null) {
+ log(sm.getString("standardWrapper.noLoader"));
throw new ServletException
(sm.getString("standardWrapper.noLoader"));
+ }
ClassLoader classLoader = loader.getClassLoader();
// Load and initialize an instance of the specified servlet class
try {
Class classClass = classLoader.loadClass(servletClass);
+ if (classClass == null) {
+ log(sm.getString("standardWrapper.noClass", servletClass));
+ throw new ServletException
+ (sm.getString("standardWrapper.noClass", servletClass));
+ }
Servlet servlet = (Servlet) classClass.newInstance();
- servlet.init((ServletConfig) this);
+ if (servlet == null) {
+ log(sm.getString("standardWrapper.noInstance", servletClass));
+ throw new ServletException
+ (sm.getString("standardWrapper.noInstance", servletClass));
+ }
+ try {
+ servlet.init((ServletConfig) this);
+ } catch (ServletException f) {
+ log(sm.getString("standardWrapper.servletInit"), f);
+ throw f; // FIXME - UnavailableException handling
+ }
instance = servlet;
} catch (Exception e) {
+ log(sm.getString("standardWrapper.loadError", servletClass), e);
throw new ServletException("load: " + e);
}
1.2 +279 -53 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/FileClassLoader.java
Index: FileClassLoader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/FileClassLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FileClassLoader.java 2000/05/09 02:35:46 1.1
+++ FileClassLoader.java 2000/05/12 00:47:25 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/FileClassLoader.java,v 1.1 2000/05/09 02:35:46 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2000/05/09 02:35:46 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/FileClassLoader.java,v 1.2 2000/05/12 00:47:25 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/05/12 00:47:25 $
*
* ====================================================================
*
@@ -75,9 +75,9 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
-import java.util.jar.JarEntry;
-import java.util.jar.JarException;
-import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
import org.apache.tomcat.util.StringManager;
@@ -89,9 +89,12 @@
* <p>
* This code was partially based on the <code>AdaptiveClassLoader</code>
* module originally copied from Apache JServ, and used in Tomcat 3.x.
+ * However, it does class loading in a different order (webapp first then
+ * system classes), and allows the set of associated repositories to be
+ * modified at runtime.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2000/05/09 02:35:46 $
+ * @version $Revision: 1.2 $ $Date: 2000/05/12 00:47:25 $
*/
public final class FileClassLoader
@@ -131,6 +134,25 @@
}
+ /**
+ * Construct a new ClassLoader instance with the specified initial list of
+ * repositories. Each element of this list must be a String that contains
+ * a pathname to a directory, a JAR file, or a ZIP file.
+ *
+ * @param repositories Initial list of repositories
+ *
+ * @exception IllegalArgumentException if one of the specified repositories
+ * does not exist, or is not of the appropriate type
+ */
+ public FileClassLoader(String repositories[]) {
+
+ super();
+ for (int i = 0; i < repositories.length; i++)
+ addRepository(repositories[i]);
+
+ }
+
+
// ---------------------------------------------------- Instance Variables
@@ -144,6 +166,7 @@
/**
* The debugging detail level of this component.
*/
+ // private int debug = 2;
private int debug = 0;
@@ -166,7 +189,7 @@
* of the elements in this Vector controls the order in which repositories
* are examined when new classes or resources are requested.
*/
- private Vector repositories = new Vector();
+ private String repositories[] = new String[0];
/**
@@ -214,42 +237,65 @@
* @exception IllegalArgumentException if the specified repository is
* invalid or does not exist
*/
- public void addRepository(String repository) {
+ public synchronized void addRepository(String repository) {
- if (repositories.contains(repository))
- return;
+ if (debug >= 1)
+ log("addRepository(" + repository + ")");
+ for (int i = 0; i < repositories.length; i++) {
+ if (repository.equals(repositories[i])) {
+ if (debug >= 1)
+ log(" This repository is already included");
+ return;
+ }
+ }
// Validate the existence, readability, and type of this repository
File file = new File(repository);
- if (!file.exists())
+ if (!file.exists()) {
+ if (debug >= 1)
+ log(" Repository does not exist");
throw new IllegalArgumentException
(sm.getString("fileClassLoader.exists", repository));
- if (!file.canRead())
+ }
+ if (!file.canRead()) {
+ if (debug >= 1)
+ log(" Repository cannot be read");
throw new IllegalArgumentException
(sm.getString("fileClassLoader.canRead", repository));
+ }
if (file.isDirectory()) {
+ if (debug >= 1)
+ log(" Repository is a directory");
directories.put(repository, file);
} else {
- JarFile jarFile = null;
+ ZipFile jarFile = null;
try {
- jarFile = new JarFile(file);
+ jarFile = new ZipFile(file);
Enumeration entries = jarFile.entries();
while (entries.hasMoreElements()) {
- JarEntry entry = (JarEntry) entries.nextElement();
+ ZipEntry entry = (ZipEntry) entries.nextElement();
InputStream is = jarFile.getInputStream(entry);
is.close();
break;
}
jarFile.close();
} catch (Throwable t) {
+ if (debug >= 1)
+ log(" Problem with this ZIP/JAR file", t);
throw new IllegalArgumentException
(sm.getString("fileClassLoader.jarFile", repository));
}
+ if (debug >= 1)
+ log(" Repository is a ZIP/JAR file");
jarFiles.put(repository, file);
}
// Add this repository to the set we know about
- repositories.addElement(repository);
+ String results[] = new String[repositories.length + 1];
+ for (int i = 0; i < repositories.length; i++)
+ results[i] = repositories[i];
+ results[results.length - 1] = repository;
+ repositories = results;
}
@@ -259,9 +305,9 @@
* loader. If there are no repositories, an empty Enumeration is
* returned.
*/
- public Enumeration findRepositories() {
+ public String[] findRepositories() {
- return (repositories.elements());
+ return ((String[]) repositories.clone());
}
@@ -272,8 +318,37 @@
*/
public boolean modified() {
- return (false); // FIXME - modified()
+ if (debug >= 2)
+ log("modified()");
+ // Build a list of the classes we currently have cached
+ Vector temp = new Vector();
+ synchronized(cache) {
+ Enumeration keys = cache.keys();
+ while (keys.hasMoreElements())
+ temp.addElement(keys.nextElement());
+ }
+
+ // Check for modifications to any of the cached classes
+ Enumeration classnames = temp.elements();
+ while (classnames.hasMoreElements()) {
+ String classname = (String) classnames.nextElement();
+ CacheEntry entry = (CacheEntry) cache.get(classname);
+ if (entry == null)
+ continue;
+ if (entry.origin == null) // System classes cannot be modified
+ continue;
+ if (entry.lastModified != entry.origin.lastModified()) {
+ if (debug >= 2)
+ log(" Class " + classname + " was modified");
+ return (true);
+ }
+ }
+
+ if (debug >= 2)
+ log(" No classes were modified");
+ return (false);
+
}
@@ -282,8 +357,13 @@
*/
public Reloader reload() {
- return (null); // FIXME - reload()
+ if (debug >= 1)
+ log("reload()");
+ FileClassLoader loader = new FileClassLoader(findRepositories());
+ loader.setDebug(getDebug());
+ return (loader);
+
}
@@ -294,10 +374,25 @@
*
* @param repository Name of the repository to remove
*/
- public void removeRepository(String repository) {
+ public synchronized void removeRepository(String repository) {
- if (repositories.contains(repository))
- repositories.removeElement(repository);
+ if (debug >= 1)
+ log("removeRepository(" + repository + ")");
+ String results[] = new String[repositories.length - 1];
+ int j = 0;
+ boolean removed = false;
+ for (int i = 0; i < repositories.length; i++) {
+ if (repository.equals(repositories[i]))
+ removed = true;
+ else
+ results[j++] = repositories[i];
+ }
+ if (debug >= 1) {
+ if (removed)
+ log(" Repository has been removed");
+ else
+ log(" Repository was not present");
+ }
}
@@ -314,14 +409,21 @@
*/
public URL getResource(String name) {
+ // if (debug >= 2)
+ // log("getResource(" + name + ")");
+
// Search for this resource in all of our repositories
- Enumeration repositories = this.repositories.elements();
- while (repositories.hasMoreElements()) {
- String repository = (String) repositories.nextElement();
+ String repositories[] = findRepositories();
+ for (int i = 0; i < repositories.length; i++) {
+ String repository = repositories[i];
+ // if (debug >= 2)
+ // log(" Checking repository " + repository);
File directory = (File) directories.get(repository);
if (directory != null) {
URL theURL =
loadResourceFromDirectory(directory, name);
+ // if ((theURL != null) && (debug >= 2))
+ // log(" Returning directory resource URL " + theURL);
if (theURL != null)
return (theURL);
}
@@ -329,13 +431,24 @@
if (jarFile != null) {
URL theURL =
loadResourceFromJarFile(jarFile, name);
+ // if ((theURL != null) && (debug >= 2))
+ // log(" Returning JAR/ZIP resource URL " + theURL);
if (theURL != null)
return (theURL);
}
}
// Load this resource from the system class path
- return (getSystemResource(name));
+ URL theURL = getSystemResource(name);
+ /*
+ if (debug >= 2) {
+ if (theURL != null)
+ log(" Returning system resource URL " + theURL);
+ else
+ log(" Cannot find this resource");
+ }
+ */
+ return (theURL);
}
@@ -348,14 +461,21 @@
*/
public InputStream getResourceAsStream(String name) {
+ // if (debug >= 2)
+ // log("getResourceAsStream(" + name + ")");
+
// Search for this resource in all of our repositories
- Enumeration repositories = this.repositories.elements();
- while (repositories.hasMoreElements()) {
- String repository = (String) repositories.nextElement();
+ String repositories[] = findRepositories();
+ for (int i = 0; i < repositories.length; i++) {
+ String repository = repositories[i];
+ // if (debug >= 2)
+ // log(" Checking repository " + repository);
File directory = (File) directories.get(repository);
if (directory != null) {
InputStream theStream =
loadStreamFromDirectory(directory, name);
+ if ((theStream != null) && (debug >= 2))
+ log(" Returning directory resource stream");
if (theStream != null)
return (theStream);
}
@@ -363,13 +483,24 @@
if (jarFile != null) {
InputStream theStream =
loadStreamFromJarFile(jarFile, name);
+ // if ((theStream != null) && (debug >= 2))
+ // log(" Returning JAR/ZIP resource stream");
if (theStream != null)
return (theStream);
}
}
// Load this resource from the system class path
- return (getSystemResourceAsStream(name));
+ InputStream theStream = getSystemResourceAsStream(name);
+ /*
+ if (debug >= 2) {
+ if (theStream != null)
+ log(" Returning system resource stream");
+ else
+ log(" Cannot find this resource");
+ }
+ */
+ return (theStream);
}
@@ -392,24 +523,33 @@
public Class loadClass(String name, boolean resolve)
throws ClassNotFoundException {
+ // if (debug >= 2)
+ // log("loadClass(" + name + ", " + resolve + ")");
+
// Has this class already been loaded?
CacheEntry entry = (CacheEntry) cache.get(name);
if (entry != null) {
Class theClass = entry.loadedClass;
if (resolve)
resolveClass(theClass);
+ // if (debug >= 2)
+ // log(" Found the class in our cache");
return (theClass);
}
// Search for this class in all of our repositories
if (allowed(name)) {
- Enumeration repositories = this.repositories.elements();
- while (repositories.hasMoreElements()) {
- String repository = (String) repositories.nextElement();
+ String repositories[] = findRepositories();
+ for (int i = 0; i < repositories.length; i++) {
+ String repository = repositories[i];
+ // if (debug >= 2)
+ // log(" Checking repository " + repository);
File directory = (File) directories.get(repository);
if (directory != null) {
Class theClass =
loadClassFromDirectory(directory, name, resolve);
+ // if ((theClass != null) && (debug >= 2))
+ // log(" Loaded from a directory");
if (theClass != null)
return (theClass);
}
@@ -417,6 +557,8 @@
if (jarFile != null) {
Class theClass =
loadClassFromJarFile(jarFile, name, resolve);
+ // if ((theClass != null) && (debug >= 2))
+ // log(" Loaded from a JAR/ZIP file");
if (theClass != null)
return (theClass);
}
@@ -424,17 +566,41 @@
}
// Load this class from the system class path
+ // if (debug >= 2)
+ // log(" Checking the system class path");
Class theClass = loadClassFromSystem(name, resolve);
+ // if ((theClass != null) && (debug >= 2))
+ // log(" Loaded from the system class path");
if (theClass != null)
return (theClass);
- else
+ else {
+ // if (debug >= 2)
+ // log(" Cannot find this class");
throw new ClassNotFoundException(name);
+ }
}
- // ------------------------------------------------------- Private Methods
+ /**
+ * Return a String representation of this class.
+ */
+ public String toString() {
+
+ StringBuffer sb = new StringBuffer("FileClassLoader[");
+ String repositories[] = findRepositories();
+ for (int i = 0; i < repositories.length; i++) {
+ if (i > 0)
+ sb.append(File.pathSeparator);
+ sb.append(repositories[i]);
+ }
+ sb.append("]");
+ return (sb.toString());
+
+ }
+
+ // ------------------------------------------------------- Private Methods
/**
@@ -521,18 +687,23 @@
name.replace('.', '/') + ".class";
// Load the bytes for this class, and define it
- JarFile jarFile = null;
- JarEntry jarEntry = null;
+ ZipFile jarFile = null;
+ ZipEntry jarEntry = null;
Class theClass = null;
- byte buffer[] = new byte[(int) jarEntry.getSize()];
InputStream is = null;
try {
- jarFile = new JarFile(jar);
- jarEntry = jarFile.getJarEntry(filename);
+ jarFile = new ZipFile(jar);
+ if (jarFile == null) {
+ // if (debug >= 2)
+ // log(" Cannot open JAR file " + jar.getAbsolutePath());
+ return (null);
+ }
+ jarEntry = jarFile.getEntry(filename);
if (jarEntry == null) {
jarFile.close();
return (null);
}
+ byte buffer[] = new byte[(int) jarEntry.getSize()];
is = new BufferedInputStream(jarFile.getInputStream(jarEntry));
is.read(buffer);
is.close();
@@ -601,8 +772,7 @@
private URL loadResourceFromDirectory(File directory, String name) {
// Translate the resource name to a filename
- String filename =
- name.replace('.', File.separatorChar) + ".class";
+ String filename = name.replace('/', File.separatorChar);
// Validate the existence and readability of this resource file
File resourceFile = new File(directory, filename);
@@ -628,8 +798,37 @@
*/
private URL loadResourceFromJarFile(File jar, String name) {
- return (null); // FIXME - loadResourceFromJarFile()
+ // Translate the resource name to a filename
+ // String filename = name.replace('.', '/');
+ String filename = name;
+ // Create an input stream for this resource
+ ZipFile jarFile = null;
+ ZipEntry jarEntry = null;
+ InputStream is = null;
+ try {
+ jarFile = new ZipFile(jar);
+ jarEntry = jarFile.getEntry(filename);
+ jarFile.close();
+ if (jarEntry == null)
+ return (null);
+ try {
+ return (new URL("jar:file:" + jar.getAbsolutePath() +
+ "!/" + name));
+ } catch (MalformedURLException e) {
+ return (null);
+ }
+ } catch (Throwable t) {
+ if (jarFile != null) {
+ try {
+ jarFile.close();
+ } catch (Throwable u) {
+ ;
+ }
+ }
+ return (null);
+ }
+
}
@@ -643,7 +842,7 @@
private InputStream loadStreamFromDirectory(File directory, String name) {
// Translate the resource name to a filename
- String filename = name.replace('.', File.separatorChar);
+ String filename = name.replace('/', File.separatorChar);
// Validate the existence and readability of this resource file
File resourceFile = new File(directory, filename);
@@ -670,15 +869,16 @@
private InputStream loadStreamFromJarFile(File jar, String name) {
// Translate the resource name to a filename
- String filename = name.replace('.', '/');
+ // String filename = name.replace('.', '/');
+ String filename = name;
// Create an input stream for this resource
- JarFile jarFile = null;
- JarEntry jarEntry = null;
+ ZipFile jarFile = null;
+ ZipEntry jarEntry = null;
InputStream is = null;
try {
- jarFile = new JarFile(jar);
- jarEntry = jarFile.getJarEntry(filename);
+ jarFile = new ZipFile(jar);
+ jarEntry = jarFile.getEntry(filename);
if (jarEntry == null) {
jarFile.close();
return (null);
@@ -700,6 +900,32 @@
}
+ /**
+ * Log a debugging output message.
+ *
+ * @param message Message to be logged
+ */
+ private void log(String message) {
+
+ System.out.println("FileClassLoader: " + message);
+
+ }
+
+
+ /**
+ * Log a debugging output message with an exception.
+ *
+ * @param message Message to be logged
+ * @param throwable Exception to be logged
+ */
+ private void log(String message, Throwable throwable) {
+
+ System.out.println("FileClassLoader: " + message);
+ throwable.printStackTrace(System.out);
+
+ }
+
+
// ------------------------------------------------------- Private Classes
@@ -723,12 +949,12 @@
* The File (for a directory) or JarFile (for a JAR) from which this
* class was loaded, or <code>null</code> if loaded from the system.
*/
- Object origin;
+ File origin;
/**
* Construct a new instance of this class.
*/
- public CacheEntry(Class loadedClass, Object origin,
+ public CacheEntry(Class loadedClass, File origin,
long lastModified) {
this.loadedClass = loadedClass;
1.3 +2 -6 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/LocalStrings.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LocalStrings.properties 2000/05/09 02:35:47 1.2
+++ LocalStrings.properties 2000/05/12 00:47:25 1.3
@@ -1,15 +1,11 @@
fileClassLoader.canRead=Repository {0} cannot be read
fileClassLoader.exists=Repository {0} does not exist
fileClassLoader.jarFile=Cannot read JAR file {0}
-standardLoader.addRepository=Adding repository {0}
standardLoader.alreadyStarted=Loader has already been started
-standardLoader.exists=Repository {0} does not exist
-standardLoader.includes= Include path {0}
-standardLoader.notStarted=Loader has not yet been started
-standardLoader.read=Repository {0} cannot be read
+standardLoader.addRepository=Adding repository {0}
standardLoader.reload=Reloading this Loader
standardLoader.reloadError=Error reloading this loader
standardLoader.removeRepository=Removing repository {0}
standardLoader.starting=Starting this Loader
+standardLoader.notStarted=Loader has not yet been started
standardLoader.stopping=Stopping this Loader
-standardLoader.type=Repository {0} is not a supported file type
1.2 +5 -14 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/Reloader.java
Index: Reloader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/Reloader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Reloader.java 2000/05/09 02:35:47 1.1
+++ Reloader.java 2000/05/12 00:47:25 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/Reloader.java,v 1.1 2000/05/09 02:35:47 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2000/05/09 02:35:47 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/Reloader.java,v 1.2 2000/05/12 00:47:25 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2000/05/12 00:47:25 $
*
* ====================================================================
*
@@ -65,16 +65,13 @@
package org.apache.tomcat.loader;
-import java.util.Enumeration;
-
-
/**
* Internal interface that <code>ClassLoader</code> implementations may
* optionally implement to support the auto-reload functionality of
* <code>StandardLoader</code>.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2000/05/09 02:35:47 $
+ * @version $Revision: 1.2 $ $Date: 2000/05/12 00:47:25 $
*/
public interface Reloader {
@@ -98,7 +95,7 @@
* loader. If there are no repositories, an empty Enumeration is
* returned.
*/
- public Enumeration findRepositories();
+ public String[] findRepositories();
/**
@@ -106,12 +103,6 @@
* is appropriate?
*/
public boolean modified();
-
-
- /**
- * Create a new ClassLoader instance based on our current repositories.
- */
- public Reloader reload();
/**
1.4 +77 -94 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StandardLoader.java 2000/05/09 02:35:47 1.3
+++ StandardLoader.java 2000/05/12 00:47:25 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java,v 1.3 2000/05/09 02:35:47 craigmcc Exp $
- * $Revision: 1.3 $
- * $Date: 2000/05/09 02:35:47 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java,v 1.4 2000/05/12 00:47:25 craigmcc Exp $
+ * $Revision: 1.4 $
+ * $Date: 2000/05/12 00:47:25 $
*
* ====================================================================
*
@@ -71,8 +71,6 @@
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
import org.apache.tomcat.Container;
import org.apache.tomcat.Lifecycle;
import org.apache.tomcat.LifecycleEvent;
@@ -80,7 +78,6 @@
import org.apache.tomcat.LifecycleListener;
import org.apache.tomcat.Loader;
import org.apache.tomcat.Logger;
-import org.apache.tomcat.loader.AdaptiveClassLoader;
import org.apache.tomcat.util.LifecycleSupport;
import org.apache.tomcat.util.StringManager;
@@ -98,7 +95,7 @@
* is not present, the system class loader will be used instead.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.3 $ $Date: 2000/05/09 02:35:47 $
+ * @version $Revision: 1.4 $ $Date: 2000/05/12 00:47:25 $
*/
public final class StandardLoader
@@ -111,7 +108,7 @@
/**
* The class loader being managed by this Loader component.
*/
- private AdaptiveClassLoader classLoader = null;
+ private Reloader classLoader = null;
/**
@@ -140,10 +137,17 @@
/**
- * The set of class repositories for this class loader. The contents of
- * this list must be directories, JAR files, and ZIP files that contain
- * the classes to be loaded by this class loader.
+ * The Java class name of the ClassLoader implementation to be used.
+ * To be useful, this ClassLoader should also implement the
+ * <code>Reloader</code> interface.
*/
+ private String loaderClass =
+ "org.apache.tomcat.loader.FileClassLoader";
+
+
+ /**
+ * The set of repositories associated with this class loader.
+ */
private Vector repositories = new Vector();
@@ -174,7 +178,7 @@
*/
public ClassLoader getClassLoader() {
- return (classLoader);
+ return ((ClassLoader) classLoader);
}
@@ -240,6 +244,28 @@
}
+ /**
+ * Return the ClassLoader class name.
+ */
+ public String getLoaderClass() {
+
+ return (this.loaderClass);
+
+ }
+
+
+ /**
+ * Set the ClassLoader class name.
+ *
+ * @param loaderClass The new ClassLoader class name
+ */
+ public void setLoaderClass() {
+
+ this.loaderClass = loaderClass;
+
+ }
+
+
// --------------------------------------------------------- Public Methods
@@ -264,11 +290,9 @@
if (debug >= 1)
log(sm.getString("standardLoader.addRepository", repository));
- if (!repositories.contains(repository)) {
- repositories.addElement(repository);
- if (started)
- reload();
- }
+ repositories.addElement(repository);
+ if (started)
+ classLoader.addRepository(repository);
}
@@ -279,12 +303,12 @@
*/
public String[] findRepositories() {
- synchronized (repositories) {
- String results[] = new String[repositories.size()];
- for (int i = 0; i < results.length; i++)
- results[i] = (String) repositories.elementAt(i);
- return (results);
- }
+ String results[] = new String[repositories.size()];
+ Enumeration elements = repositories.elements();
+ int i = 0;
+ while (elements.hasMoreElements())
+ results[i++] = (String) elements.nextElement();
+ return (results);
}
@@ -295,10 +319,7 @@
*/
public boolean modified() {
- if (classLoader != null)
- return (classLoader.shouldReload());
- else
- return (false);
+ return (classLoader.modified());
}
@@ -347,11 +368,23 @@
if (debug >= 1)
log(sm.getString("standardLoader.removeRepository", repository));
- if (repositories.contains(repository)) {
- repositories.removeElement(repository);
- if (started)
- reload();
- }
+ repositories.removeElement(repository);
+ if (started)
+ classLoader.removeRepository(repository);
+
+ }
+
+
+ /**
+ * Return a String representation of this component.
+ */
+ public String toString() {
+
+ StringBuffer sb = new StringBuffer("StandardLoader[");
+ if (container != null)
+ sb.append(container.getName());
+ sb.append("]");
+ return (sb.toString());
}
@@ -398,37 +431,18 @@
log(sm.getString("standardLoader.starting"));
lifecycle.fireLifecycleEvent(START_EVENT, null);
started = true;
-
- // Validate the specified repositories
- Vector files = new Vector();
- Enumeration names = repositories.elements();
- while (names.hasMoreElements()) {
- File file = new File((String) names.nextElement());
- files.addElement(file);
- String path = null;
- try {
- path = file.getCanonicalPath();
- } catch (IOException e) {
- path = "UNKNOWN";
- }
- if (!file.exists())
- throw new LifecycleException
- (sm.getString("standardLoader.exists", path));
- else if (!file.canRead())
- throw new LifecycleException
- (sm.getString("standardLoader.read", path));
- else if (!checkType(file))
- throw new LifecycleException
- (sm.getString("standardLoader.type", path));
- if (debug >= 1)
- log(sm.getString("standardLoader.includes", path));
- }
- // Construct a new class loader instance for our use
+ // Construct a class loader based on our current repositories list
try {
- classLoader = new AdaptiveClassLoader(files);
- } catch (IllegalArgumentException e) {
- throw new LifecycleException("start: ", e);
+ Class clazz = Class.forName(loaderClass);
+ classLoader = (Reloader) clazz.newInstance();
+ Enumeration elements = repositories.elements();
+ while (elements.hasMoreElements())
+ classLoader.addRepository((String) elements.nextElement());
+ if (classLoader instanceof Lifecycle)
+ ((Lifecycle) classLoader).start();
+ } catch (Throwable t) {
+ throw new LifecycleException("start: ", t);
}
}
@@ -451,45 +465,14 @@
started = false;
// Throw away our current class loader
+ if (classLoader instanceof Lifecycle)
+ ((Lifecycle) classLoader).stop();
classLoader = null;
}
// ------------------------------------------------------- Private Methods
-
-
- /**
- * Is the specified file an appropriate entry for a repository?
- *
- * @param file The repository entry to be validated
- */
- private boolean checkType(File file) {
-
- // Directories are acceptable
- if (file.isDirectory())
- return (true);
-
- // ZIP and JAR files that we can recognize are acceptable
- boolean isArchive = true;
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile(file);
- } catch (ZipException e) {
- isArchive = false;
- } catch (IOException e) {
- isArchive = false;
- }
- if (zipFile != null) {
- try {
- zipFile.close();
- } catch (IOException e) {
- ;
- }
- }
- return (isArchive);
-
- }
/**
1.7 +11 -11 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java
Index: StandardResources.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StandardResources.java 2000/05/08 19:16:25 1.6
+++ StandardResources.java 2000/05/12 00:47:26 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java,v 1.6 2000/05/08 19:16:25 craigmcc Exp $
- * $Revision: 1.6 $
- * $Date: 2000/05/08 19:16:25 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java,v 1.7 2000/05/12 00:47:26 craigmcc Exp $
+ * $Revision: 1.7 $
+ * $Date: 2000/05/12 00:47:26 $
*
* ====================================================================
*
@@ -101,7 +101,7 @@
* </ul>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.6 $ $Date: 2000/05/08 19:16:25 $
+ * @version $Revision: 1.7 $ $Date: 2000/05/12 00:47:26 $
*/
public final class StandardResources
@@ -279,12 +279,12 @@
fileBase = null;
int colon = this.docBase.indexOf(":");
if (colon <= 1) // No colon, or Windows drive letter
- fileBase = docBase;
+ fileBase = this.docBase;
if (this.docBase.startsWith("file:")) {
if (this.docBase.startsWith("file://"))
- fileBase = docBase.substring(7);
+ fileBase = this.docBase.substring(7);
else
- fileBase = docBase.substring(5);
+ fileBase = this.docBase.substring(5);
if ((fileBase.length() > 2) &&
(fileBase.charAt(1) == '|'))
fileBase =
@@ -295,17 +295,17 @@
if (fileBase != null) {
File file = new File(fileBase);
if (!file.isAbsolute()) {
- file = new File(System.getProperty("catalina.home") +
- File.separator + fileBase);
+ file = new File(System.getProperty("catalina.home"), fileBase);
fileBase = file.getAbsolutePath();
+ file = new File(fileBase);
}
+ if (debug >= 1)
+ log(" Also setting fileBase to '" + fileBase + "'");
if (!file.isDirectory())
throw new IllegalArgumentException
(sm.getString("standardResources.directory", fileBase));
}
- if (debug >= 1)
- log(" Also setting fileBase to '" + fileBase + "'");
}
1.3 +16 -4 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/SnoopAllServlet.java
Index: SnoopAllServlet.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/SnoopAllServlet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SnoopAllServlet.java 2000/05/05 22:45:39 1.2
+++ SnoopAllServlet.java 2000/05/12 00:47:26 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/SnoopAllServlet.java,v 1.2 2000/05/05 22:45:39 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/05/05 22:45:39 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/SnoopAllServlet.java,v 1.3 2000/05/12 00:47:26 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/05/12 00:47:26 $
*
* ====================================================================
*
@@ -81,7 +81,7 @@
* into an HTML page.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/05/05 22:45:39 $
+ * @version $Revision: 1.3 $ $Date: 2000/05/12 00:47:26 $
*/
public final class SnoopAllServlet
@@ -186,6 +186,18 @@
request.getServletPath());
writer.println("<li><b>userPrincipal</b> = " +
request.getUserPrincipal());
+ writer.println("</ul>");
+ writer.println("<hr>");
+
+ // Document the servlet context attributes
+ writer.println("<h1>ServletContext Attributes</h1>");
+ writer.println("<ul>");
+ attrs = getServletContext().getAttributeNames();
+ while (attrs.hasMoreElements()) {
+ String attr = (String) attrs.nextElement();
+ writer.println("<li><b>" + attr + "</b> = " +
+ getServletContext().getAttribute(attr));
+ }
writer.println("</ul>");
writer.println("<hr>");