dev@glassfish.java.net

ASClassLoaderUtil needs to consider domain_root/lib/classes and domain_root/lib/[*.jar|*.zip]

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Thu, 20 Oct 2005 12:52:24 -0700

Hi Siva,

I noticed when we configure JspC (from
com.sun.enterprise.deployment.backend.JSPCompiler, for JSP
precompilations during deployment) and JspServlet (from
com.sun.enterprise.web.WebModuleListener, for JSP compilations
at runtime) with the classpath for "javac" to use, we call:

  ASClassLoaderUtil.getWebModuleClassPath(<module_id>)

I've noticed that this classpath does not include
domain_root/lib/classes or domain_root/lib/[*.jar|*.zip].

Right now, I am adding those paths "manually" (using the code below)
when configuring the JspServlet (from WebModuleListener), but I still
need to do this when configuring JspC (from JSPCompiler).

It would help if those path names where already included in the
classpath returned by ASClassLoaderUtil.

Also, the JSP compiler currently distinguishes between 2 class paths:
the "system class path" and a webapp's "local class path", which
includes a webapp's bundled class files and JARs. Currently, the
"local class path" is already included in the "system class path",
since the "system class path" is set using

  ASClassLoaderUtil.getWebModuleClassPath(<module_id>).

Would it be possible to provide another utility in ASClassLoaderUtil
that returned what
ASClassLoaderUtil.getWebModuleClassPath(<module_id>) currently returns
minus the webapp specific path components?


So, in summary, I'm looking for a new utility in ASClassLoaderUtil that:

- includes domain_root/lib/classes and domain_root/lib/[*.jar|*.zip],
  and
- does not include any webapp specific path components

in the returned classpath.


Let me know if you think this makes sense or if i am missing anything.

Thanks!


Jan


com.sun.enterprise.web.WebContainer.getInstanceClassPath():

    /*
     * Gets the instance classpath, which is composed of the pathnames
     * of domain_root/lib/classes and domain_root/lib/[*.jar|*.zip] (in
     * this order), separated by the path-separator character.
     *
     * @param instanceEnv The instance whose classpath is to be
     * determined
     *
     * @return The instance classpath
     */
    private String getInstanceClassPath(InstanceEnvironment instanceEnv) {

        if (instanceEnv == null) {
            return null;
        }

        StringBuffer sb = new StringBuffer();

        File libDir = new File(instanceEnv.getLibPath());
        String libDirPath = libDir.getAbsolutePath();

        // Append domain_root/lib/classes
        sb.append(libDirPath + File.separator + "classes");
        sb.append(File.pathSeparator);

        // Append domain_root/lib/[*.jar|*.zip]
        String[] files = libDir.list();
        if (files != null) {
            for (int i=0; i<files.length; i++) {
                if (files[i].endsWith(".jar") ||
files[i].endsWith(".zip")) {
                    sb.append(libDirPath + File.separator + files[i]);
                    sb.append(File.pathSeparator);
                }
            }
        }

        return sb.toString();
    }