Create a new bundle from a 3rd party jar

From RifidiWiki

Jump to: navigation, search

When it is necessary to add functionality from a third party, follow these steps:

  1. Look for an OSGi bundle provided from another source. For example, the Eclipse Orbit project takes many commonly used libraries and turns them into bundles that other people can use. If you find a bundle from a third party, you can use it by including it in your target platform. You can either put it in the target platform itself, or you can put it in a folder like org.rifidi.binaries/thirdparty that contains bundles.
  2. If you cannot find a bundle that someone else has already made, you will need to create the bundle yourself.
    1. The easiest way to do this is to import the jar using the "Plugin From Existing Jar Archive" wizard in Eclipse. You will find this wizard in New->Plugin Development.
    2. Use the wizard to import the jar. Give it a name that is the same name as the root level package. For example, the bundle that provides the ActiveMQ libaray is called org.apache.activemq.
    3. Make sure that the proper packages are exported. It is important to add include the version information of the library in the exported packages. For example, all of the packages exported in the org.apache.activemq are versioned at 1.5.1 because the version of the ActiveMQ library is 1.5.1.
    4. You can now export the plugin and put it in your target platform or a folder such as org.rifidi.binaries/thirdparth that your target platform points to.
  3. When you use your new bundle in another plugin, make sure that you use import-package rather than require-bundle. Also, make sure that the version of the packages that you import are the same as the ones that you exported in the plugin.
Personal tools