POJO Service Registry brings OSGi to the Classpath

| by Alex Blewitt Follow 4 Followers on Apr 20, 2011. Estimated reading time: 2 minutes |

A new project on Google Code, the Pojo Service Registry, aims to provide an OSGi-lite mechanism for Java applications, but outside of a OSGi runtime.

Although OSGi is known for its strong approach to modularity, sometimes the use of multiple classloaders (required in order to be able to dynamically install, update and remove bundles) causes problems with libraries that assume a flat classpath. However, a key benefit of programming against the OSGi μservice model is that implementations and clients need have no prior knowledge of their implementations in order to be wired up.

The aim of the Pojo Service Registry is to provide a means to take advantage of the OSGi service model, but without the multiple classloaders and dynamic bundle requirements. The same APIs and signatures are used, but in order to locate a service in PojoSR the classpath is scanned for any services that are exported in an OSGi-like manner. In addition, bundle activators are automatically started as part of the classpath scanning at startup.

Although it has been referred to as OSGi-lite, it remains to be seen whether the OSGi namespace and APIs can continue to be used, since it is not part of the official OSGi specification. On the other hand, it has inspired many to pick up and work with it, including getting an implementation of Felix on Google App Engine; a demonstration app is available at

Getting Felix to run on Google App Engine is not as simple as it seems; for example, GAE does not allow threads to be created (and inherently the OSGi framework is multi-threaded) – but with a few minor modifications (including making the event notification framework synchronous) allows the runtime to be bootstrapped.

One other aspect is that since the class path is computed based on the set of JARs on the classpath, any nested bundles (using Bundle-ClassPath) won't be resolved. This has led some to question whether it is better to embed or inline nested dependencies – though arguably, in a PojoSR approach where the classpath is flat, it may make sense to do neither and externalise the dependency as its own bundle.

PojoSR allows projects to migrate towards using OSGi μservices without having to go the full OSGi way, and provide services by adjusting the contents of the classpath rather than the contents of an XML file. Whether it gets officially blessed or tolerated by the OSGi Alliance remains to be seen.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you