Thursday, October 09, 2008

Converting legacy code into OSGi bundles

Any person who starts to do something serious with OSGi soon hits a wall; issues with legacy code such as;

  1. Calls to System.exit()
  2. Starting up using main(String[]) method
  3. Using the Thread Context Classloader (TCCL)
Due to such issues, it seems like it is next to impossible to make use of legacy code without code changes & recompiling. However, this is impractical since

  1. The source may not be available
  2. Modification of source code may violate copyright
  3. It may be practically impossible to find & fix all instances of violations
This is one of the major issues we faced while making the functionality in the WSO2 Java products into OSGi compatible Carbon components.

The Knopflerfish OSGi framework has come up with a solution to address these concerns; bytecode level patching at runtime. The violations are located & patched at runtime. There is a very good presentation by OSGi veterans Gunnar Ekolin & Erik Wistrand from Makewave titled 'Everything Can be a Bundle', which is a MUST READ for any OSGi newbie & even for people who have been working with OSGi for sometime.

0 comments: