DPML
DPML Transit ClassLoaders
HomeUtilitiesStationMetro
Classloader Construction

Layered above the Transit artifact protocol handler is a system that provides support for the creation of classloaders. Classloaders are described under a 'plugin' file which is basically a list of dependent artifact uris and their location in the classloader hierarchy. The plugin file is itself normally referenced as an artifact which means that the list is itself versioned, named, associated with a group, and dynamically resolvable.

Example classloader descriptor artifact uri:

@METRO-TOOLS-URI@

The plugin file declares PUBLIC, PROTECTED and PRIVATE classloaders where each classloader is defined in terms of jar artifact uris. Transit uses this information to construct a classloader chain.

Plugin files use a XML file format to declare features of of the classloader, including information used when resolving plugins. This information is normally created automatically using the Plugin Builder from the Depot build system.

The following code fragment demonstrates the relatively simple process of creating a new classloader using Transit.

URI uri = new URI( "artifact:part:dpml/examples/hello/hello-world#1.0.0" );
Part part = Part.load( uri );
ClassLoader classloader = part.getClassloader();

The following code fragment demonstrates the equivalent functionality using strict Java core classes.

URI uri = new URI( "artifact:part:dpml/examples/hello/hello-world#1.0.0" );
ClassLoader classloader = (ClassLoader) uri.toURL().getContent( new Class[]{ ClassLoader.class } );