Wednesday, May 25, 2011

Dragging Geotools kicking and screaming to OSGi land

Me and others have been making some noise on the Geotools list to convert the current modules in Geotools from being only modules in name to proper OSGi bundles with services being published for use by other bundles and packages being imported and exported cleanly.

There seem to have been several attempts to osgify the Geotools mud-ball with only the bits the users needed to get things done being taken care of and hard bit, particularly those using the Sun ServiceLoader interface being left out.
  1. Classic example from Harald Wellman currently hosted on Berlios
  2. Argeo attempt - Mathieu is putting the OSGi modification back into Geotools core
  3. Humboldt project - Same idea using Bnd.

There are 2 solutions to the META-INF/services dilemma (introduced by the classloader separation inherent in OSGi)
  1. A bundle lifecycle interceptor that picks up all the SPI based services and converts them to OSGi service.
  2. A compile time mangler that does the same conversion and adds OSGI-INF/*.xml for the services.
The reference factories being registered look pretty nice in ASCII art.

The other issue plaguing the migration of geotools is the presence of split package, another ripple from the OSGi classloader per bundle approach. There are various hacks to solve this, but none of them is quite neat. As a stop-gap package can be merged using the split directive in the manifest or via Bnd.

Hope the transformation will be over soon and we will have truly modular Geotools.

    No comments: