com.waveset.util
Class LHClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended bycom.waveset.util.LHClassLoader

public class LHClassLoader
extends java.net.URLClassLoader

Lighthouse custom class loader (in effect) sets its own CLASSPATH.

This classloader is used for two purposes:

  1. to extend the environment
  2. to override the environment class path (e.g., in cases where the JRE does not support JCE 1.2.1 or the default classloader does not perform the secure class loading that JCE 1.2.1 requires).

LHClassLoader extends the environment by dynamically adding archives to the effective classpath. This allows us to get around problems setting the CLASSPATH environment variable due to Windows command line length limits). This also allows Lighthouse to automatically pick up JAR or ZIP files needed for site-specific policies or custom resource adapters.

LHClassLoader overrides the environment by constructing a parentless class loader. This creates a separate name space for classes, which allows Lighthouse to support JCE 1.2.1 even when the JRE does not (e.g., when the default classloader does not perform the secure class loading that JCE 1.2.1 requires). This also allows Lighthouse to avoid conflicts with pluggable extensions (such as JCE providers or JDBC drivers) placed in the CLASSPATH or bundled with an application server.

When an object of this class is initialized, it determines which directory it will search for classes, and which directory it will search for archives (i.e., files with the extension ".zip" or ".jar"). Whenever it is asked to find a class or a resource, the LHClassLoader will first search the directory specified by "waveset.lib", and then search every archive it found in that directory.

The LHClassLoader normally works off the value of system property "waveset.home". It confirms that the value of waveset.home is the path to a valid directory, and then looks for a "WEB-INF/classes" and a "WEB-INF/lib" directory directly beneath the directory specified by "waveset.home". The LHClassLoader then searches the "lib" directory for archives.

If Java system property "waveset.lib" has been defined, the LHClassLoader confirms that the value of waveset.lib is the path to a valid directory. The LHClassLoader then searches the specified directory for archives. In this case, "waveset.lib" is both the "classes" and the "lib" directory.

The LHClassLoader requires a minimal set of archives. Specifically, initialization fails if it cannot find "idm.jar" and "j2ee.jar". The LHClassLoader then imposes minimal ordering of the listed archives, placing the required jars (in the order they were specified as required) at the beginning of the search sequence.

Whenever it is asked to find a class or a resource, the LHClassLoader first searches the "classes" directory, and then searches every archive it found in the "lib" directory.

NOTE: The LHClassLoader is often initialized with a null parent, which means that the classpath specified the CLASSPATH environment variable is ignored. This prevents problems that can occur when two jars contain conflicting entries. For example, suppose you want to use Oracle's JDBC driver, but the appserver (whose jar is in the system classpath) bundles its own driver for Oracle.


Field Summary
static java.lang.String code_id
           
static java.lang.String WAVESET_LIB
           
 
Method Summary
protected  java.lang.Class findClass(java.lang.String name)
           
 java.net.URL findResource(java.lang.String name)
           
static java.lang.ClassLoader getClassLoader(java.lang.ClassLoader parent)
          Java system property waveset.home or waveset.lib must already have been set in order for the class loader to find the right jars.
static java.util.List getJarFiles(java.net.URL wavesetHomeUrl)
           
 boolean getVerbose()
           
 java.lang.Class loadClass(java.lang.String name)
          Overridden to load selfishly (altering the normal delegation) so that LHClassLoader can extend the effective classpath.
 java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Overridden to load selfishly (altering the normal delegation) so that LHClassLoader can extend the effective classpath.
protected static void println(java.lang.Object o)
           
 void setVerbose(boolean verbose)
           
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

WAVESET_LIB

public static final java.lang.String WAVESET_LIB
See Also:
Constant Field Values
Method Detail

getVerbose

public boolean getVerbose()

setVerbose

public void setVerbose(boolean verbose)

getClassLoader

public static java.lang.ClassLoader getClassLoader(java.lang.ClassLoader parent)
                                            throws java.lang.Exception
Java system property waveset.home or waveset.lib must already have been set in order for the class loader to find the right jars.

Throws:
java.lang.Exception

println

protected static void println(java.lang.Object o)

getJarFiles

public static java.util.List getJarFiles(java.net.URL wavesetHomeUrl)
                                  throws java.io.IOException,
                                         InvalidArgument,
                                         InternalError
Parameters:
wavesetHomeUrl -
Returns:
a list of URLs to jar or zip files that belong in the Lighthouse classpath, with any required jars correctly ordered at the head of the list.
Throws:
java.io.IOException
InvalidArgument
InternalError

loadClass

public java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Overridden to load selfishly (altering the normal delegation) so that LHClassLoader can extend the effective classpath.

Throws:
java.lang.ClassNotFoundException

loadClass

public java.lang.Class loadClass(java.lang.String name,
                                 boolean resolve)
                          throws java.lang.ClassNotFoundException
Overridden to load selfishly (altering the normal delegation) so that LHClassLoader can extend the effective classpath.

Throws:
java.lang.ClassNotFoundException

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

findResource

public java.net.URL findResource(java.lang.String name)