remm 01/01/23 20:32:20
Modified: catalina/src/share/org/apache/catalina/loader
StandardLoader.java
Log:
- Should complete the Jasper Runtime Environment.
- JARs are copied to the work directory. The class loader doesn't use these.
- Classes from /WEB-INF/classes are copied to {workdir}/classes.
- All of these repositories are then added to the "Jasper classpath".
- All the Jasper specific methods are clearly marked as being Jasper specific.
Revision Changes Path
1.17 +50 -29
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java
Index: StandardLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- StandardLoader.java 2001/01/24 02:34:06 1.16
+++ StandardLoader.java 2001/01/24 04:32:20 1.17
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v
1.16 2001/01/24 02:34:06 remm Exp $
- * $Revision: 1.16 $
- * $Date: 2001/01/24 02:34:06 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v
1.17 2001/01/24 04:32:20 remm Exp $
+ * $Revision: 1.17 $
+ * $Date: 2001/01/24 04:32:20 $
*
* ====================================================================
*
@@ -82,6 +82,7 @@
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.directory.DirContext;
+import org.apache.naming.resources.Resource;
import org.apache.naming.resources.DirContextURLStreamHandler;
import org.apache.naming.resources.DirContextURLStreamHandlerFactory;
import org.apache.catalina.Container;
@@ -111,7 +112,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.16 $ $Date: 2001/01/24 02:34:06 $
+ * @version $Revision: 1.17 $ $Date: 2001/01/24 04:32:20 $
*/
public final class StandardLoader
@@ -603,13 +604,6 @@
// Construct a class loader based on our current repositories list
try {
- /*
- URLStreamHandlerFactory shFactory = null;
- if ((this.container != null) &&
- (this.container.getResources() != null)) {
- shFactory = new DirContextURLStreamHandlerFactory();
- }
- */
if (parentClassLoader == null)
classLoader = new StandardClassLoader();
else
@@ -795,8 +789,8 @@
*/
private void setJasperEnvironment() {
setClassLoader();
- copyClassesRepository();
setClassPath();
+ copyClassesRepository();
}
@@ -824,7 +818,12 @@
// Looking up directory /WEB-INF/classes in the context
try {
- resources.lookup(classesName);
+ Object object = resources.lookup(classesName);
+ if (object instanceof DirContext) {
+ resources = (DirContext) object;
+ } else {
+ return;
+ }
} catch(NamingException e) {
return;
}
@@ -836,19 +835,12 @@
if (workDir != null) {
if (!(classpath.equals("")))
- classpath += File.pathSeparator;
+ classpath = File.pathSeparator + classpath;
File classesDir = new File(workDir, "/classes");
- classpath += classesDir.getAbsolutePath();
+ classesDir.mkdir();
+ classpath = classesDir.getAbsolutePath() + classpath;
- try {
- NamingEnumeration enum = resources.list(classesName);
- while (enum.hasMoreElements()) {
- NameClassPair ncPair =
- (NameClassPair) enum.nextElement();
- String filename = ncPair.getName();
- }
- } catch (NamingException e) {
- }
+ copyDir(resources, classesDir);
}
@@ -860,8 +852,40 @@
/**
* Copy directory.
*/
- private boolean copyDir(DirContext directory) {
+ private boolean copyDir(DirContext srcDir, File destDir) {
+
+ try {
+
+ NamingEnumeration enum = srcDir.list("");
+ while (enum.hasMoreElements()) {
+ NameClassPair ncPair =
+ (NameClassPair) enum.nextElement();
+ String name = ncPair.getName();
+ Object object = srcDir.lookup(name);
+ File currentFile = new File(destDir, name);
+ if (object instanceof Resource) {
+ InputStream is = ((Resource) object).streamContent();
+ OutputStream os = new FileOutputStream(currentFile);
+ if (!copy(is, os))
+ return false;
+ } else if (object instanceof InputStream) {
+ OutputStream os = new FileOutputStream(currentFile);
+ if (!copy((InputStream) object, os))
+ return false;
+ } else if (object instanceof DirContext) {
+ currentFile.mkdir();
+ copyDir((DirContext) object, currentFile);
+ }
+ }
+
+ } catch (NamingException e) {
+ return false;
+ } catch (IOException e) {
+ return false;
+ }
+
return true;
+
}
@@ -919,8 +943,7 @@
else
continue;
if (repository.endsWith("/"))
- repository =
- repository.substring(0, repository.length() - 1);
+ continue;
if (n > 0)
classpath.append(File.pathSeparator);
classpath.append(repository);
@@ -989,8 +1012,6 @@
servletContext.setAttribute(Globals.CLASS_PATH_ATTR,
classpath.toString());
- System.out.println("Classpath: " + classpath);
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]