Making Legacy Java OSGi Compatible

Session Type: 
Standard [35 minutes]
Speakers

Although OSGi is increasingly popular, there are many Java applications and libraries that have not been designed to work in OSGi. Sometimes you may need to run such code inside an OSGi environment, either because you would like to take advantage of the benefits offered by OSGi itself, or because you need certain features only offered by this particular environment. Often, you can't afford to migrate entirely to OSGi or at least you need a transition period during which your code works fine both in and outside OSGi. And surely, you would like to do this with minimum effort and without increasing the complexity of your software.

Recently, our team at SAP faced a similar challenge. While addressing it, we learned a lot about this topic and so I would like to share our most interesting findings.

In order for legacy Java code to run smoothly inside an OSGi environment, it should meet a number of prerequisites, among them the following:

  • It is packaged as OSGi bundles.
  • It adheres to restrictions imposed by OSGi regarding loading classes dynamically.
  • Each package is exported by exactly one bundle.

Note that meeting the above requirements means neither that you should rewrite your code so that it only runs in OSGi, nor that you should fundamentally change your development environment to be based on OSGi. On the contrary, it is quite possible to achieve compatibility with OSGi without losing the capability to run outside OSGi, and without changing dramatically your development approaches and tools.

For more information, see the following blog post: http://www.stoyanr.com/2012/09/making-plain-old-java-osgi-compatible.html.

Schedule info

Status: 
Declined

Audience

Track: 
OSGi DevCon
Experience level: 
Beginner

Copyright © 2013 The Eclipse Foundation. All Rights Reserved.