The goal of the bootstrap module is to create the initial environment for a server. Normally this sort of bootstrap is handled by java directly via command line arguments to the java executable or via manifest entries in an executable jar. Unfortunately, the bootstrap built into Java is so limited and hard to work with that it is often augmented with shell scripts to generate the command line arguments. The xbean-bootstrap module will support the following features:
- Creation of a bootstrap class loader which is a child of the system class loader. This leaves the system class loader clean of the bootstrap classes, which makes class loader isolation much easier.
- Support for ant style pattern matching for the specification of the bootstrap class path. Normally one writes a shell script to find all jars and zips in the lib directory, or one has to list the exact name of each jar.
- Pluggable bootstrap loaders. The bootstrap code determines what should be loaded (normally this is a file but is it really just a string so anything goes), and finds loader that can handle the resource (this will normally be the spring loader).
- Bootstrap jar should be reusable. In most cases, the default values should be good enough for a server. In cases where defaults need to be changed, the manifest can be modified to change them.
- Bootstrap should be completely self contained meaning no dependencies.
- Bootstrap should do as little as possible. Create the class loader, create the loader, start the loading, and get out of the way.
The bootstrap code will need a bunch of properties to start up, and there are many way to get properties into the server. This is a little something I learned from OpenEJB is we load properties in layers from multiple sources and then present the final startup code with a single properties object.
Another trick from OpenEJB is the system properties on the command line come from the left side of the java class name and to make life easy you also scan the command line args for aditional -Dname=value properties. Then you just add those properties to the system making the admin's life easier.
- System properties
| Property || Default || Description |
| xbean.base.dir || if can locate startup jar or startup classes dir (the one containing a the bootstrap class)|
if startup jar is named "bin" use parent else use startup jar
else throw error
| The base directory of the server. This is simply set into the environment.|
| xbean.bootstrap.ClassPath || lib/*.jar lib*.zip || The paths used for the bootstrap class loader. |
| xbean.bootstrap.ClassLoaderFactory || UrlClassLoaderFactory || The factory used to create the bootstrap class loader. |
| xbean.bootstrap.Loader || Use xbean-finder to search class path for file named META-INF/org/xbean/bootstrap/loader.properties || The class used to load the bootstrap resource |
- Process properties
- determine base dir and set into system property xbean.base.dir
- determine class path
- determine class loader factory
- determine the bootstrap loader
- Resolve class path
- Create class loader
- Create the bootstrap loader
- Call loader passing in the class loader, properties, and cli args (without any consumed during bootstrap)