I have a large ecosystem of applications and libraries which are currently deployed as a collection of .jars in various application servers (e.g. JBoss AS), and I'm trying to figure out a good set of tools to manage dependencies and life-cycles of the various packages.
I think of the packages as being in one of (at least) three possible states: "unloaded", "pending" and "loaded", loosely defined as follows:
- Unloaded: The package is not available at the moment.
- Pending: The package itself is available, but not all its dependencies. Therefore, it cannot be used at the moment.
- Loaded: The package is available and has all its dependencies satisfied. If it's an application, it can run - if it's a library, it is ready to be used by another package.
(There might also be a few more states, such as "failed" for packages that tried to load but failed for some other reason than that dependencies were not satisfied, etc...)
In the life-cycle of a package, a number of things might cause a package to change state between these three:
- A package with no dependencies is loaded, and goes from unloaded to loaded.
- A package tries to load, but not all dependencies are satisfied; it goes from unloaded to pending.
- A package in pending state suddenly has all its dependencies satisfied (because some other package went to state loaded), and automatically starts loading itself; transition from pending to loaded.
- A package is unloaded. All loaded packages which depend on the now unloaded package go from loaded to pending.
- A package is updated to a newer version. All dependent packages are automatically reloaded, to get access to the updated version.
I've started working on using OSGi for defining the dependencies - it rolls well with our build system and produces reliable dependency information. However, if I load the two OSGi bundles A
and B
into JBoss, where B
depends on A
, and then unload A
, it seems like B
happily keeps running. I've understood that there are some hooks that I could use to control this on a low level (framework events), but my spider sense is tingling, saying that there must be a better way to do this.
Is there a nice tool/framework/whatever-you-want-to-call-it that will compliment OSGi in these aspects?