API UsageThe Java API can be used to create new realms and connect realms together through importation of specific packages.
The core of the
ClassWorld world = new ClassWorld();
Once a
ClassWorld world = new ClassWorld(); ClassRealm containerRealm = world.newRealm( "container" ); ClassRealm logComponentRealm = world.newRealm( "logComponent" );
In order to make each
containerRealm.addConstituent( containerJarUrl ); logComponentRealm.addConstituent( logComponentJarUrl ); Now, links between the various realms need to be created to allow classes loaded from one to be available to classes loaded in another. logComponentRealm.importFrom( "container", "com.werken.projectz.component" ); The container implementation can then be loaded from it's realm and used. Class containerClass = containerRealm.loadClass( CONTAINER_CLASSNAME ); MyContainer container = (MyContainer) containerClass.newInstance(); Thread.currentThread().setContextClassLoader( containerRealm.getClassLoader() ); container.run();
Ideally, the container itself would be responsible for creating
a
|