Class Loaders

J5m platform can run with a single class loader, or it uses several class loaders as requested by an implementation of bootstrap interface.

The single class loader configuration is suitable for j5m utilities which start the platform and execute a single task. In this case, the platform and the utility JAR are distributed as a set of JARs available on a class path, so it is effective to start everything as a monolithic application. The respective implementation is provided by LooseBootstrap class.

However, a multi class loader setup is the typical configuration. This configuration ensures several envelopes for j5m modules and user's applications:

Class Loader Id (equal to Code Base) Note
http:j5m:fundamentals "Fundamentals" module that initializes j5m platform and defines fundamental interfaces
http:j5m:kernel "Kernel" module that implements the fundamental API (e.g. pools, HA routines) and defines core j5m annotations for users' applications
http:j5m:spi An instance of this class loader is allocated for each registry SPI
http:j5m:nugget "Nugget" module that implements all major j5m services for users' applications
http:j5m:app:... Class loader of appp:... user application

The structure of class loaders is defined by an implementation of bootstrap interface. The standard ParanoiaBootstrap class constructs this dependency tree:

 <JRE system class loader>
  +--- http:j5m:fundamentals
        +--- http:j5m:kernel
              +--- http:j5m:spi
              +--- http:j5m:nugget
              +--- http:j5m:app:...

It ensures that a user application can load its versions of various libraries without collision with the libraries used in "nugget" or "SPI" modules. On the other hand, user application could collide with "kernel" and "fundamentals" spaces. These two spaces never use (and will never use) other JARs, thus the collision is impossible unless the application uses its own version of the two modules. The standard assembly may never cause this situation, because all j5m's system JARs are always excluded from the application JAR.