Create a new bundle from a 3rd party jar
From RifidiWiki
When it is necessary to add functionality from a third party, follow these steps:
- 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. - If you cannot find a bundle that someone else has already made, you will need to create the bundle yourself.
- 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.
- 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
. - 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. - 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.
- When you use your new bundle in another plugin, make sure that you use
import-package
rather thanrequire-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.