You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2003/03/12 07:33:37 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader WebappLoader.java
costin 2003/03/11 22:33:37
Modified: catalina/src/share/org/apache/catalina/loader
WebappLoader.java
Log:
Few getters ( Remy: don't panic, I'm not changing the loader ! ).
The array will collect the loaders that are set into the class loader
and allow JMX to view the actual classpath ( if the loader is registered ).
I also added a bit more info in case something is missing.
Knowing the exact classpath of a webapp can be extremely usefull when debugging
strange bugs...
Revision Changes Path
1.9 +48 -10 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappLoader.java
Index: WebappLoader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappLoader.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebappLoader.java 8 Mar 2003 17:01:20 -0000 1.8
+++ WebappLoader.java 12 Mar 2003 06:33:37 -0000 1.9
@@ -1,7 +1,4 @@
/*
- * $Header$
- * $Revision$
- * $Date$
*
* ====================================================================
*
@@ -82,6 +79,7 @@
import java.net.URLStreamHandlerFactory;
import java.security.Permission;
import java.util.jar.JarFile;
+import java.util.ArrayList;
import javax.servlet.ServletContext;
import javax.naming.NamingException;
import javax.naming.Binding;
@@ -103,6 +101,8 @@
import org.apache.catalina.Logger;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
@@ -126,7 +126,6 @@
public class WebappLoader
implements Lifecycle, Loader, PropertyChangeListener, Runnable {
-
// ----------------------------------------------------------- Constructors
@@ -271,6 +270,11 @@
private String threadName = "WebappLoader";
+ // Classpath set in the loader
+ private String classpath=null;
+
+ // repositories that are set in the loader, for jmx
+ private ArrayList loaderRepositories;
// ------------------------------------------------------------- Properties
@@ -347,6 +351,7 @@
/**
* Return the DefaultContext with which this Loader is associated.
+ * XXX What is that ???
*/
public DefaultContext getDefaultContext() {
@@ -527,6 +532,7 @@
if (started && (classLoader != null)) {
classLoader.addRepository(repository);
+ if( loaderRepositories != null ) loaderRepositories.add(repository);
setClassPath();
}
@@ -549,6 +555,8 @@
return ((String[])repositories.clone());
}
+ /** Extra repositories for this loader
+ */
public String getRepositoriesString() {
StringBuffer sb=new StringBuffer();
for( int i=0; i<repositories.length ; i++ ) {
@@ -557,6 +565,30 @@
return sb.toString();
}
+ public String[] getLoaderRepositories() {
+ if( loaderRepositories==null ) return null;
+ String res[]=new String[ loaderRepositories.size()];
+ loaderRepositories.toArray(res);
+ return res;
+ }
+
+ public String getLoaderRepositoriesString() {
+ String repositories[]=getLoaderRepositories();
+ StringBuffer sb=new StringBuffer();
+ for( int i=0; i<repositories.length ; i++ ) {
+ sb.append( repositories[i]).append(":");
+ }
+ return sb.toString();
+ }
+
+ /** Classpath, as set in org.apache.catalina.jsp_classpath context
+ * property
+ *
+ * @return
+ */
+ public String getClasspath() {
+ return classpath;
+ }
/**
* Has the internal repository associated with this Loader been modified,
@@ -639,7 +671,6 @@
* @exception LifecycleException if a lifecycle error occurs
*/
public void start() throws LifecycleException {
-
// Validate and update our current component state
if (started)
throw new LifecycleException
@@ -649,9 +680,10 @@
lifecycle.fireLifecycleEvent(START_EVENT, null);
started = true;
- if (container.getResources() == null)
+ if (container.getResources() == null) {
+ log.info("No resources for " + container);
return;
-
+ }
// Register a stream handler factory for the JNDI protocol
URLStreamHandlerFactory streamHandlerFactory =
new DirContextURLStreamHandlerFactory();
@@ -964,11 +996,13 @@
if (servletContext == null)
return;
+ loaderRepositories=new ArrayList();
// Loading the work directory
File workDir =
(File) servletContext.getAttribute(Globals.WORK_DIR_ATTR);
- if (workDir == null)
- return;
+ if (workDir == null) {
+ log.info("No work dir for " + servletContext);
+ }
if( log.isDebugEnabled())
log.debug(sm.getString("webappLoader.deploy", workDir.getAbsolutePath()));
@@ -1016,6 +1050,7 @@
// Adding the repository to the class loader
classLoader.addRepository(classesPath + "/", classRepository);
+ loaderRepositories.add(classesPath + "/" );
}
@@ -1079,6 +1114,7 @@
JarFile jarFile = new JarFile(destFile);
classLoader.addJar(filename, jarFile, destFile);
+ loaderRepositories.add( filename );
}
} catch (NamingException e) {
@@ -1151,6 +1187,8 @@
loader = loader.getParent();
layers++;
}
+
+ this.classpath=classpath.toString();
// Store the assembled class path as a servlet context attribute
servletContext.setAttribute(Globals.CLASS_PATH_ATTR,
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader WebappLoader.java
Posted by Costin Manolache <cm...@yahoo.com>.
Remy Maucherat wrote:
>> + for( int i=0; i<repositories.length ; i++ ) {
>> + sb.append( repositories[i]).append(":");
>> + }
>
> I think your should use the path separator here.
You're right. I put it in mostly for debug. I'll fix it.
Costin
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader
WebappLoader.java
Posted by Remy Maucherat <re...@apache.org>.
costin@apache.org wrote:
> costin 2003/03/11 22:33:37
>
> Modified: catalina/src/share/org/apache/catalina/loader
> WebappLoader.java
> Log:
> Few getters ( Remy: don't panic, I'm not changing the loader ! ).
Ok :)
> The array will collect the loaders that are set into the class loader
> and allow JMX to view the actual classpath ( if the loader is registered ).
>
> I also added a bit more info in case something is missing.
>
> Knowing the exact classpath of a webapp can be extremely usefull when debugging
> strange bugs...
> + for( int i=0; i<repositories.length ; i++ ) {
> + sb.append( repositories[i]).append(":");
> + }
I think your should use the path separator here.
Remy
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org