User: jules_gosnell Date: 02/03/19 11:43:11 Modified: jetty/src/main/org/jboss/jetty JBossWebApplicationContext.java Log: walk the classloader tree building a classpath for Jasper. This will migrate into AbstractWebContainer when it stabilises. No NJar support yet - we need a way to translate an NJar URL into the file that is cached behind it... Revision Changes Path 1.34 +106 -21 contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java Index: JBossWebApplicationContext.java =================================================================== RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/JBossWebApplicationContext.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- JBossWebApplicationContext.java 16 Mar 2002 01:16:38 -0000 1.33 +++ JBossWebApplicationContext.java 19 Mar 2002 19:43:11 -0000 1.34 @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -// $Id: JBossWebApplicationContext.java,v 1.33 2002/03/16 01:16:38 jules_gosnell Exp $ +// $Id: JBossWebApplicationContext.java,v 1.34 2002/03/19 19:43:11 jules_gosnell Exp $ // A Jetty HttpServer with the interface expected by JBoss' // J2EEDeployer... @@ -34,6 +34,10 @@ import org.mortbay.util.Resource; import org.xml.sax.InputSource; +import java.util.Iterator; +import java.util.List; +import java.util.ArrayList; + //------------------------------------------------------------------------------ public class @@ -169,35 +173,116 @@ public String getFileClassPath() { - String[] entries=_jetty.getCompileClasspath(getClassLoader()); - + List List=new ArrayList(); + getFileClassPath(getClassLoader(), List); - // temporary fix until - // AbstractWebContainer.getCompileClasspath () returns non-URL - // entries - // NOTE: this fix won't work for the njar URLs String classpath=""; - for (int i=0; i<entries.length; i++) + for (Iterator i=List.iterator(); i.hasNext();) { - try - { - Resource res = Resource.newResource (entries[i]); - if (res.getFile()==null) - _log.warn("bad classpath entry: "+entries[i]); - else - classpath+=(classpath.length()==0?"":_separator)+res.getFile().getCanonicalPath(); - } - catch (IOException ioe) + URL url=(URL)i.next(); + +// if (url.getProtocol().equals("njar")) +// { +// try +// { +// URLConnection conn=url.openConnection(); +// //url=conn.getURL(); +// _log.warn("JSP CONNECTION: "+conn); +// } +// catch (IOException ignore) +// { +// } +// } + + if (!url.getProtocol().equals("file")) // tmp warning { - _log.warn ("JSP Classpath is damaged, can't convert path for :"+entries[i], ioe); + _log.warn("JSP classpath: non-'file' protocol: "+url); + continue; } - } - if (_log.isDebugEnabled()) - _log.debug("JSP classpath: "+classpath); + try + { + Resource res = Resource.newResource (url); + if (res.getFile()==null) + _log.warn("bad classpath entry: "+url); + else + { + String tmp=res.getFile().getCanonicalPath(); + // _log.info("JSP FILE: "+url+" --> "+tmp+" : "+url.getProtocol()); + if (classpath.indexOf(tmp)==-1) + classpath+=(classpath.length()==0?"":_separator)+tmp; + } + } + catch (IOException ioe) + { + _log.warn ("JSP Classpath is damaged, can't convert path for :"+url, ioe); + } + } + _log.info("JSP classpath: "+classpath); return classpath; } + + public void + getFileClassPath(ClassLoader cl, List list) + { + if (cl==null) + return; + + URL[] urls=null; + + if (cl instanceof org.jboss.system.UnifiedClassLoader) + urls=((org.jboss.system.UnifiedClassLoader)cl).getAllURLs(); + else if (cl instanceof org.jboss.system.MBeanClassLoader) + urls=((org.jboss.system.MBeanClassLoader)cl).getURLs(); + else if (cl instanceof java.net.URLClassLoader) + urls=((java.net.URLClassLoader)cl).getURLs(); + + // _log.info("CLASSLOADER: "+cl); + // _log.info("URLs: "+(urls!=null?urls.length:0)); + + if (urls!=null) + for (int i=0; i<urls.length; i++) + { + URL url=urls[i]; + // _log.info("URL: "+url); + if (!list.contains(url)) + list.add(url); + } + + getFileClassPath(cl.getParent(), list); + } + +// public String +// getFileClassPath(ClassLoader cl) +// { +// String classpath=""; +// String[] entries=_jetty.getCompileClasspath(cl); +// +// for (int i=0; i<entries.length; i++) +// { +// try +// { +// Resource res = Resource.newResource (entries[i]); +// if (res.getFile()==null) +// _log.warn("bad classpath entry: "+entries[i]); +// else +// { +// String tmp=res.getFile().getCanonicalPath(); +// classpath+=(classpath.length()==0?"":_separator)+tmp; +// } +// } +// catch (IOException ioe) +// { +// _log.warn ("JSP Classpath is damaged, can't convert path for :"+entries[i], ioe); +// } +// } +// +// if (_log.isDebugEnabled()) +// _log.debug("JSP classpath: "+classpath); +// +// return classpath; +// } // given a resource name, find the jar file that contains that resource... protected String
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development