All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class WebSite.Servlet.ServletClassLoader

java.lang.Object
   |
   +----WebSite.Servlet.ServletClassLoader

public class ServletClassLoader
extends Object

Special class loader that can reload classes after modification. This is provided primarily for development environments, to alleviate the need for restarting the web server when a loaded servlet class has been modified and recompiled. There is a significant performance and memory penalty to using this reloading facility, so it is not recommended that you use this on production server systems. You can avoid using this class loader by putting your classes somewhere on the normal class path.

Do not directly access this class. It is used internally by the WebSite.Servlet package. It is not a subclass of java.lang.CLassLoader. It uses a private class that does the actual dirty work, and which subclasses java.lang.ClassLoader.

Classes to be checked and reloaded on update must be placed under a specific directory called the reloadable directory. This is essentially a special class path directory that is used only by this class loader. The directory is typically configured to be the path ...\WebSite\Java\classes\Reloadable. This must not appear in the server's configured class path!

Loading sequence

This loader first tries to load classes via the normal class path. If a class is not found via the class path, it then uses the reloadable directory as the root for a class search. So, for example, to find the class foo.bar.blat it looks for <reload-dir>\foo\bar\blat.class.

If this fails, and the class is part of a package (in our example, package foo.bar) it looks for a jar or a zip file that contains the class. The search starts with the most specific name (in our example <reload-dir>\foo.bar.[jar|zip]) and tries for a jar file first, then a zip file. If is doesn't find either, it will strip successive elements from the name (in our example <reload-dir>\foo.[jar|zip]), and try jar then zip at eash stage. If it finds one, it will open it and look for the class using the pathname syntax as usual (\foo\bar\blat.class for our example) within the jar or zip archive. The archives may be compressed.

Reloading heuristics

When the Java VM asks this loader for a class that it has previously loaded as "reloadable" (via the reloadable directory), it always checks the date of the file on disk and compares it to the date the file had when it was previously loaded. If the class came from a jar file, the date of the jar file is used for comparison. If the file on disk is newer, the newer class replaces the older one in the Java VM.

Changing the reloadable directory

WebSite Professional 2.0 has no provision in its user interface to configure the reloadable directory. If you want to move its location from the installation default, edit the registry at:
HKEY_LOCAL_MACHINE
    Software
        Denny
            WebServer
                CurrentVersion
                    Java
and change the ReloadableDir value to the path you want.


Constructor Index

 o ServletClassLoader(String, boolean)

Method Index

 o loadClass(String)

Constructors

 o ServletClassLoader
 public ServletClassLoader(String dirName,
                           boolean debug)

Methods

 o loadClass
 public Class loadClass(String className) throws ClassNotFoundException

All Packages  Class Hierarchy  This Package  Previous  Next  Index