Dynamic class loading

Related Topics ...

Overview: Configuring a Development Environment

Eclipse-based Development Environments

The Factory dynamically loads Java classes from the directory or directories specified in the bowstreet.dynamic.class.load.path property. The default value of the property is the Factory's WEB-INF/work/classes directory.

 

How Class Loading Works

The Designer compiles classes from source to the WEB-INF/temp directory. When compilation is complete, an ANT script is used to copy the compiled classes from the WEB-INF/temp directory to the WEB-INF/work/classes directory. Contents of this directory are loaded dynamically and do not require a server restart for changes to take effect. Any Java source changes can thus be seen instantly in WEB-INF/work/classes. This is useful for development where source code changes frequently.

Where JAR files are concerned, the WEB-INF/work/lib directory is the functional equivalent of the WEB-INF/work/classes directory. JAR files in WEB-INF/work/lib are updated by the Designer when the project is re-built.

Because Eclipse-based IDEs clean the directory to which they compile the Java classes for the project, Factory projects use a temporary build directory to which the project's Java classes get compiled. An Ant script then copies the compiled classes to the WEB-INF/work/classes directory.

This is done so that we can include classes in the WEB-INF/work/classes without having the Java source file, which is a common occurrence when packaging and sharing models that use LJOs or packaging and sharing builders that you create.

 

Factory and Designer Class and JAR Directories

The following directories are used for the storage of Java class and JAR files.

In the Factory file system:

  • WEB-INF/classes - A Static directory used by the Factory to store class files. Classes are loaded at server startup and not checked for changes. Server restart is required to refresh this directory and see file changes.

  • WEB-INF/lib - A Static directory used by the Factory to store JAR files. JARs are loaded at server startup and not checked for changes. Server restart is required to refresh this directory and see JAR changes.

In the Designer file system:

  • WEB-INF/work/classes -- A dynamic directory used by the Designer to store class files. Changes to files are seen immediately.

  • WEB-INF/work/lib - A dynamic directory used by the Designer to store JAR files. Changes to JAR files are seen immediately.

 

Tips for Working with Class and JAR Files

  • When doing development, keep classes and JAR files under the WEB-INF/work directory. Once development is complete, we can turn off dynamic class loading on the deployment machine to improve application performance.

  • Create a separate project for managing your WebSphere Portlet Factory Java artifacts and use an Ant script to copy these classes to work/classes.

  • Use JAR files to distribute builders and other JAVA-based items you create.