costin 01/06/16 13:18:49
Modified: src/share/org/apache/tomcat/modules/config
LoaderInterceptor11.java
Log:
Return the real classpath, including common and parent.
Revision Changes Path
1.11 +59 -1
jakarta-tomcat/src/share/org/apache/tomcat/modules/config/LoaderInterceptor11.java
Index: LoaderInterceptor11.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/LoaderInterceptor11.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- LoaderInterceptor11.java 2001/03/10 07:22:20 1.10
+++ LoaderInterceptor11.java 2001/06/16 20:18:49 1.11
@@ -80,6 +80,7 @@
public class LoaderInterceptor11 extends BaseInterceptor {
boolean useAL=false;
boolean useNoParent=false;
+ private int attributeInfo;
public LoaderInterceptor11() {
}
@@ -97,6 +98,13 @@
useNoParent=b;
}
+ public void engineInit( ContextManager cm )
+ throws TomcatException
+ {
+ attributeInfo=cm.getNoteId(ContextManager.REQUEST_NOTE,
+ "req.attribute");
+ }
+
/** Add all WEB-INF/classes and WEB-INF/lib to the context
* path
*/
@@ -157,7 +165,8 @@
/** Construct another class loader, when the context is reloaded.
*/
public void reload( Request req, Context context) throws TomcatException {
- log( "Reload event " + context.getPath() );
+ if( debug > 0 )
+ log( "Reload event " + context.getPath() );
// construct a new loader
ClassLoader oldLoader=context.getClassLoader();
@@ -206,7 +215,56 @@
}
// --------------------
+ private static final String separator =
+ System.getProperty("path.separator", ":");
+
+ public final Object getInfo( Context ctx, Request req,
+ int info, String k )
+ {
+ if( req!=null )
+ return null;
+ if( info== attributeInfo ) {
+ // request for a context attribute, handled by tomcat
+ if( ! k.startsWith( "org.apache.tomcat" ) )
+ return null;
+ if (k.equals("org.apache.tomcat.jsp_classpath")) {
+ return getClassPath(ctx);
+ }
+ if(k.equals("org.apache.tomcat.classloader")) {
+ return ctx.getClassLoader();
+ }
+
+ }
+ return null;
+ }
+ static Jdk11Compat jdkProxy=Jdk11Compat.getJdkCompat();
+
+ private String getClassPath(Context ctx) {
+ StringBuffer cpath=new StringBuffer();
+ // local context class path
+ URL classPaths[]=ctx.getClassPath();
+ convertClassPath( cpath , classPaths );
+
+ ClassLoader parentLoader=ctx.getContextManager().getParentLoader();
+ // apps class path
+ convertClassPath(cpath, jdkProxy.getParentURLs(parentLoader));
+ // common class loader
+ convertClassPath(cpath, jdkProxy.getURLs(parentLoader));
+ if( debug>9 )
+ log("Getting classpath " + cpath);
+ return cpath.toString();
+ }
+
+ private void convertClassPath( StringBuffer cpath, URL classPaths[] ) {
+ if( classPaths==null ) return;
+ for(int i=0; i< classPaths.length ; i++ ) {
+ URL cp = classPaths[i];
+ if (cpath.length()>0) cpath.append( separator );
+ cpath.append(cp.getFile());
+ }
+ }
+
static final Jdk11Compat jdk11Compat=Jdk11Compat.getJdkCompat();
private void getJars(Vector v, File f) {