Using a REST Console to administer OSGi runtime in GlassFish
What are our options to administer OSGi runtime in GlassFish? We have already talked about
a) a command line tool, and
b) a web console.
We now have a third option. Recently I came across a REST based console being developed by Filippo Diotalevi. We already have all the necessary support in GlassFish - the REST console requires OSGi/HTTP Service and we have an implementation of the same in GlassFish. So, I thought I would give it a try and I found it a smooth ride.
How to install the REST console:
Here are the simple steps to install them:
0. Start GlassFish (I usually run "java -jar glassfish/modules/glassfish.jar"). I suggest you use v3 build #62 or higher available at http://download.java.net/glassfish/v3/promoted
That's all. If you are watching the GlassFish logs, you can see GlassFish detecting the new OSGi bundles and starting them.
Using the REST console
To list all the bundles in the system, we can run:
To see the details of a particular bundle (let;'s say bundle with id 100), run:
The above commands are requesting data in text format. You can get it in XML and have a style sheet to nicely present it in a suitable format.
If you refer to the usage page, you will find commands for installing new bundles, controlling life cycle of bundles and querying bundle headers, services, etc.
This is the true benefit of using OSGi. The bundles are very portable. REST console needs OSGi/HTTP service and GlassFish has one. As long as that requirement is met, it runs successfully. Good job Filippo! I look forward to a proper release of the REST console. Those who are interested in OSGi may like to subcribe to his blog the OSGi Look, where he not only aggregates interesting OSGi related articles but also makes available his own content.