Search code examples
osgirestletrestlet-2.0

Restlet converter registration in OSGI environment


We run Restlet 2.1 in an OSGi environment (Equinox) as bundle (ie. not as library within a bundle). The problem is that the Restlet Engine does not detect helpers (like converters) that are provided by Restlet extensions. Specifically, the EngineClassLoader#getResources() call does not return any result. The extensions are also deployed as OSGi bundles in the target platform.

Is automatic converter registration actually supposed to work within OSGi environments?


Solution

  • In fact, Restlet supports such feature thanks to a dedicated activator (see the Activator class in the package org.restlet.engine.internal).

    This activator introspects bundles to find out the following things:

    • servers corresponding to registered servers
    • servers corresponding to registered clients
    • authenticators corresponding to registered clients
    • converters

    Be aware that to use this feature, we must use the OSGi edition of Restlet since it's the only that has the MANIFEST file of the org.restlet bundle with the activator class specified. Otherwise you don't have to care about the bundle loading order...

    Hope it helps you. Thierry