Skip to content

ThirdPartyLibraries

kasemir edited this page Apr 7, 2016 · 3 revisions

Adding 3rd Party Libraries

There are different ways to include third-party libraries in CS-Studio. In order of preference:

Orbit

The Orbit repository provides some common libraries in a p2 repo for Eclipse products to use. If a library is in the Orbit repository, it is preferable to use this version.

Maven OSGi Bundles

The maven-osgi-bundles repo is used by CS-Studio to do a similar bundling, grabbing jar files from Maven Central and providing them in a p2 repo. If the jars from Maven Central are already bundled, they are not changed. If they are not bundled it uses a tool called BND to create an OSGi bundle for those jars.

There are two ways to add an artifact to maven-osgi-bundles:

  • add the library to repository/pom.xml
  • if you need more control over how the bundle is configured, you may need to follow the examples in the epics directory. This uses the Apache Felix Maven Bundle Plugin.

cs-studio-thirdparty

As a last resort, wrap jars your own way.

Buddy Class Loading

Libraries like jython, jersey, serialization, need access to class loaders beyond their own one. For example, a display builder may invoke jython, and the jython script then needs to invoke code in the display builder.

If the jython.jar is included in the display builder, i.e. they are all within the same class loader, this is no problem. But if the jython code resides in its own bundle, jython scripts execute with the class loader of the jython bundle, lacking access to the display builder code.

The solution is the buddy class loader:

  1. The Python plugin MANIFEST.MF includes <Eclipse-BuddyPolicy>registered</Eclipse-BuddyPolicy>. The pom.xml in the maven-osgi-bundles repo includes instructions to modify the original jython bundle by adding the Eclipse-BuddyPolicy.

  2. Every plugin that allows jython scripts to access its API add Eclipse-RegisterBuddy: org.python.jython to their MANIFEST.MF

In combination, plugins that allow access to their API will thus be included in the list of "buddies" and appear in the jython class loader.

Clone this wiki locally