Skip to main content

Using a REST Console to administer OSGi runtime in GlassFish

Posted by ss141213 on September 4, 2009 at 4:58 AM PDT

Introduction

 

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

1. Download GlassFish OSGi/HTTP Service bundle and copy it to glassfish/domains/domain1/autodeploy-bundles/.

2. Download the REST Console bundle and copy it to the same directory (i.e., glassfish/domains/domain1/autodeploy-bundles/).

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

I will show you a couple of commands here. To use the console, you need a HTTP client. You can refer to the usage page for more information. I am using cURL. It is installed by default in many OS.

To list all the bundles in the system, we can run:

curl http://localhost:8080/osgi/restconsole/bundles/.txt

To see the details of a particular bundle (let;'s say bundle with id 100), run:
curl http://localhost:8080/osgi/restconsole/bundles/100.txt

 

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.

 

Conclusion

 

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.

Related Topics >>

Comments

Thanks!

Hi Sahoo, I'm glad you found and tried the Rest-Console. I really need to clean it up a bit and add a few features (Configuration Admin first, maybe also support for Basic Authentication). I hope I can release something "stable" and documented in a few weeks.