You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by gl...@apache.org on 2001/03/21 13:37:29 UTC
cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper JspEngineContext.java
glenn 01/03/21 04:37:29
Modified: jasper/src/share/org/apache/jasper JspEngineContext.java
Log:
The classpath needed by javac is now built dynamically by using getURLs
on the Context URLClassLoader and all its parent class loaders except
for the system class loader. This removes the need to pass a context
attribute for the classpath between Tomcat and Jasper.
This also fixed a problem with a bad class path element due to
Jasper not understanding jndi named URL's.
Revision Changes Path
1.6 +33 -6 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspEngineContext.java
Index: JspEngineContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspEngineContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JspEngineContext.java 2001/02/08 13:37:27 1.5
+++ JspEngineContext.java 2001/03/21 12:37:20 1.6
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspEngineContext.java,v 1.5 2001/02/08 13:37:27 glenn Exp $
- * $Revision: 1.5 $
- * $Date: 2001/02/08 13:37:27 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspEngineContext.java,v 1.6 2001/03/21 12:37:20 glenn Exp $
+ * $Revision: 1.6 $
+ * $Date: 2001/03/21 12:37:20 $
*
* ====================================================================
*
@@ -145,17 +145,44 @@
/**
* The classpath that is passed off to the Java compiler.
+ *
+ * Uses the URLClassLoader getURLs to build the classpath
+ * for the Context ClassLoader and all parent
+ * ClassLoader's except for the system class loader.
*/
public String getClassPath() {
+ StringBuffer cpath = new StringBuffer();
+ ClassLoader cl = loader;
+ while( cl != null && cl.getParent() != null ) {
+ if( (cl instanceof URLClassLoader) ) {
+ cpath.append(getClassLoaderPaths((URLClassLoader)cl));
+ }
+ cl = cl.getParent();
+ }
+ return cpath.toString() + classpath;
+ }
+
+ /**
+ * The classpaths for a URLClassLoader
+ */
+ private String getClassLoaderPaths(URLClassLoader loader) {
URL [] urls = loader.getURLs();
StringBuffer cpath = new StringBuffer();
String sep = System.getProperty("path.separator");
for(int i = 0; i < urls.length; i++) {
- cpath.append((String)urls[i].getFile()+sep);
+ String file = null;
+ String url = urls[i].toString();
+ if( url.startsWith("jndi:") ) {
+ file = getRealPath(url.substring(5));
+ } else if( url.startsWith("jar:jndi:") ) {
+ file = getRealPath(url.substring(9,url.length()-2));
+ } else {
+ file = (String)urls[i].getFile();
+ }
+ cpath.append(file + sep);
}
-
- return cpath.toString() + classpath;
+ return cpath.toString();
}
/**