GlassFish V3 runs on OSGi
By dochez on Apr 11, 2008
As some of you may remember when I introduced the HK2 project last year, I described it as a friendly environment to OSGi where we would eventually be capable of running GlassFish V3 on top of an OSGi runtime. Thanks to the good work of Sahoo, this vision has finally been completed and I am happy to report that since last week, we are now capable to run GlassFish V3 on top of Apache Felix, one of the OSGi runtime available to the open source community.
In fact, we have also tried KnopflerFish (I like the name of course) and it runs fine so we are pretty confident that any OSGi runtime will be supported with minimum effort.
Now the interesting question that everyone will be asking soon, are we switching to OSGi as our underlying module subsystem ? Today I can say yes, we will. Some people might say that we changed our mind about OSGi, we didn't. From the beginning I always said we wanted to be friendly to OSGi, we just realized that vision... It is pretty clear that there is a big industry support for OSGi and it is important that GlassFish can be part of that excitement. I cannot commit on which implementation we will eventually use because we are still experimenting with some of them and we need to following conditions to be met :
\* open source
\* friendly license to one of our dual open source licenses as well as to our Java EE licensees.
\* good community (forums, mailing list) to get our questions answered
\* possibility of a commiter to be able to push our bug fixes.
Whichever implementation we choose will get a huge boost from this endorsement because we will certainly have engineers capable of fixing bugs, adding features but also we have top performance engineers at Sun that will help with the overall performance of the OSGi runtime.
Sahoo will probably blog in a day or two explaining in details the technicalities of the solution we adopted but let me introduce it here. We are still capable of running in both HK2 mode and in OSGi mode, I am not sure how long we will maintain the HK2 mode but so far the startup is a lot faster in HK2 (1 second) versus OSGi (2 seconds). Ok no big deal I suppose but we will work on that. It's hardly surprising that HK2 is faster, it is not meant to be a generic modular subsystem like OSGi, it is quite optimized for our V3 work !
None of GlassFish code depends on OSGi libraries (or very very little), we isolated those dependencies in HK2 which makes it very easy for us to switch OSGi runtimes or even module management runtime with no code changes. The HK2 project will continue as it is offering a lot more than just module management, in particular we have the following features that we continue to use heavily :
\* module management isolation layer
\* module management through Repositories (coming in OSGi R5)
\* lightweight component model
\* dependency injection
\* configuration handling
So if you want to play with the OSGi version of GlassFish V3, I would recommend downloading the latest binaries from there.
It's our latest build, don't expect miracle and please file bugs when you find one.
and to run GlassFish in OSGi mode, simply do from your installation directory
java -DGlassFish_Platform=Felix -jar modules/glassfish-10.0-SNAPSHOT.jar
to run in hk2 mode, just do
java -jar modules/glassfish-10.0-SNAPSHOT.jar