Hansa Internals
Bootstrapping
Hansa needs to be able to bootstrap itself without any particular initialization phase. The first call to the Hansa system typically arrives through the instantiation of a Handler, for instance org.ops4j.hansa.artifact.Handler.
This Handler is a delegating class, which is as simple as it can be to avoid its need to be reloaded in the future of a 24/7 system, due to it being cached by the JVM/JDK classes.
So, the Handler retrieves the delegate of the protocol by calling
m_delegate = Hansa.instance().getDelegate( protocol );
And the Hansa must be able to bootstrap from this. Hansa.instance() will initialize the system, if that has not been done before. The following steps are taken
- Determine if Hansa is residing in the System Classloader. If not so, then it tries to install a URLStreamHandlerFactory, which is capable of delegating for the supported protocols. If that fails, then Hansa can not be used.
- Hansa calls BootStrap.createBootClassloader().
- BootStrap will read org.ops4j.hansa.impl.jar system property, and if found that is the filename of the HansaProvider implementation on the local file system. If that system property does not exist, BootStrap will allocate a file in workingdir/lib, where workingdir is read from org.ops4j.hansa.working.dir system property, or if not found, set it to $HOME/.hansa on Unix/Linux and to %APPDATA%\Hansa on Windows.
- If the file in the previous step exists, then it is used, otherwise BootStrap first downloads it to that location.
- BootStrap then uses that Jar file to create a Classloader.
- Hansa then instantiate a HansaProvider from the classloader established in previous step. The HansaProvider must always called org.ops4j.hansa.provider.Impl as this is a hardcoded classname in the Hansa bootstrap sequence.
HansaProvider implementation
The default HansaProvider implementation will automatically load up the default setup and protocols. This is to fast track deployment of standard setups.
On initialize() the configuration is read;
- Default Config - resource named hansa-default.properties.
- Application Config - installdir/conf/hansa.properties
- Context Config - workdir/conf/hansa.properties
- Local Config - resource named hansa.properties
- User Config - workdir/conf/user.properties