jrunx.util
Class DynamicClassLoader
java.lang.Object
|
+--java.lang.ClassLoader
|
+--java.security.SecureClassLoader
|
+--java.net.URLClassLoader
|
+--jrunx.util.JRunURLClassLoader
|
+--jrunx.resource.ResourceURLClassLoader
|
+--jrunx.util.DynamicClassLoader
- public class DynamicClassLoader
- extends ResourceURLClassLoader
This class is a URLClassLoader that does automatic reloading and
automatic compilation. The class provides the following:
- the ability to reload a Class when a dependent class changes
(servlet/JSP/Tag handler)
- the ability to compile a class for a java file when needed
and possible
- the ability to track relationships between classes such that
steps can be taken to insure that ClassCastExceptions aren't
possible
- minimal disruption by only reloading necessary classes and
leaving unaffected classes alone
To use this class, you can not simply create an instance and load the
class you wish to use it on. Instead, you must call loadClass() on
the class each time you wish to check if it needs to be reloaded,
usually called when the class is to be instantiated.
We use a classloader within this classloader to actually load the
classes. We get a new classloader when:
- the class we're trying to load changes
- a class referenced in the class we're trying to load changes
Note that the old ClassLoader still exists, we just no longer have
a reference to it. It will stay around until all objects that were
defined with it have been garbage collected.
From 12.7 of Java Lang. Spec.:
Reloading may not be transparent if, for example, the class has:
- static variables (whose state would be lost)
- static initializers (which may have side effects)
- native methods (which may retain static state)
- Author:
- Tom Reilly, Brian Deitte
|
Method Summary |
static java.lang.String |
convertSlashName(java.lang.String name)
|
protected java.lang.Class |
findClass(java.lang.String name)
|
static java.util.Set |
getClassDependencies(java.lang.Class cls)
|
static jrunx.util.ClassConstantPool |
read(java.io.InputStream stream)
|
| Methods inherited from class java.net.URLClassLoader |
definePackage, findResources, getPermissions, getURLs, newInstance, newInstance |
| Methods inherited from class java.security.SecureClassLoader |
defineClass |
| Methods inherited from class java.lang.ClassLoader |
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setSigners |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DynamicClassLoader
public DynamicClassLoader(java.net.URL[] urls)
DynamicClassLoader
public DynamicClassLoader(java.net.URL[] urls,
boolean compile)
DynamicClassLoader
public DynamicClassLoader(java.net.URL[] urls,
java.lang.ClassLoader parent,
boolean compile)
findClass
protected java.lang.Class findClass(java.lang.String name)
throws java.lang.ClassNotFoundException
- Overrides:
findClass in class JRunURLClassLoader
getClassDependencies
public static java.util.Set getClassDependencies(java.lang.Class cls)
read
public static jrunx.util.ClassConstantPool read(java.io.InputStream stream)
throws java.io.IOException
convertSlashName
public static java.lang.String convertSlashName(java.lang.String name)
Copyright � 2002 Macromedia Corporation. All Rights Reserved.