In most cases, when you modify a Java class definition during development, you must not only recompile the class, but also reassemble your application to load the new class definition. Nucleus can also use a disposable Class Loader to instantiate components and to resolve class names in general, which under some circumstances you might be able to use to reduce the number of times you need to reassemble your application during development. This disposable Class Loader loads classes from one or more directories defined by the atg.nucleus.class.path system variable. The value of this variable is a comma-delimited list of directories or URLs. These classes must not exist in the regular CLASSPATH; if they do, they are loaded by the regular class loader and are not reloadable. Nucleus then uses a special disposable Class Loader to load the classes specified by atg.nucleus.class.path, if it cannot find those classes in the regular CLASSPATH.

To use the Class Loader:

The disposable class loader does not work with any code that uses java.lang.Class.forName to resolve a class,.

Use Caution in Making New Class Loaders

Every Java Class has a reference to the class loader that loaded it. Classes of the same name loaded by two different class loaders are considered to be completely different. This causes instanceof checks to fail, even if the class is identical in both loaders. As a result, you need to be very careful when using the disposable Class Loader feature. It is very easy to find yourself in a situation where you have two components that appear to be identical, but are in fact inconsistent.

For example, you might perform these tasks:

If arbitrary2 resolves arbitrary1 as an Object and casts it to the type Arbitrary, a ClassCastException is thrown. The disposable Class Loader feature, therefore, is really most helpful when you have a set of classes to be reloaded whose instances are easy to completely expunge from the server prior to creating a Class Loader.


Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices