Gert Vanthienen's blog

Monday, March 15, 2010

When JBI meets OSGi, part 1

In ServiceMix 4.2.0, you'll be able to deploy your existing JBI artifacts alongside OSGi bundles.

In a mixed environment like that, you might run into the situation where you want to access a class defined in an OSGi bundle from within your existing JBI SU. To allow you to that without having to add the JAR to your SU (effectively adding a second definition of the same class to the container), you can now reference an OSGi bundle as a shared library directly from your SU xbean.xml file using osgi:<bundle symbolic name>.

An example: you have a nice Camel InterceptStrategy implementation in an OSGi bundle and you're using that in a lot of your OSGi based Camel routes. You can now reuse the same code in a JBI SU for servicemix-camel by adding this snippet to your xbean.xml or camelContext.xml


  <classpath>
    <library>osgi:my.intercept.bundle.symbolic.name</library>
  </classpath>