Tuesday, 20 May 2008

Axis2 and OSGi

Thanks to Davanum for the heads up about the OSGi bundle hidden away in side the Axis2 trunk. I intend to try and run it, but having just had a look at the code it seems a little incomplete in the Activator of the bundle at least:

Activator.java :
- If the services it depends on are not available (HttpService, LogService) then it continues to activate, when really it should throw an exception, or even better use a ServiceTracker to dynamically track the services.

- What if there's more than one HttpService?

- It requests a LogService then uses System.out

- It registers itself as a bundle listener before creating an instance of the ServiceRegistry. In the unlikely event that a bundle state changes while this bundle is activating you could get a NullPointerException in the bundleChanged when trying to called the methods on the registry instance.

- Note the big block of code already commented out... that would stop any services which are already registered from being exposed as web services. Remember that OSGi is a very dynamic environment things can come and go as well as already be there when your bundles start.

- While not strictly required (I believe), during the stop() method it is good practice to call ungetService on any services references that have been acquired.

As for the rest of the code, I'm not qualified to comment as I don't know the inner workings of Axis2, so I'm just going to give it a try and see what happens. Watch this space.

1 comment:

davanum said...

Now you know why it's hidden away :) we are just getting our feet wet as you can see. Hopefully i can get back to active development of that code sometime soon. thx. definitely will incorporate your feedback.