Skip to content

Latest commit

 

History

History

org.eclipse.pde.bnd.ui

OSGi Reusable Components for bndlib

The bndlib offers various ways to build better OSGi bundles, this is used in

  • felix-bundle-plugin
  • bnd-maven-plugin
  • Tycho
  • bndtools
  • PDE itself
  • ...

This plugin offers a set of reusable UI components for these usecase to be integrated with Eclipse IDE in a way that is not specific to a given tooling (e.g. PDE, bndtools, m2e, ...) and therefore can be shared across these to prevent duplicate efforts, see here for more details.

General concepts for integration

One problem for such a reusable component is that it usually needs to get holds of some objects in an specific way that is specific to a given tooling. To mitigate we use the Eclipse Adapter Pattern as it is widely used in Eclipse, flexible and allows the use of OSGi services / Dependency Injection already.

The IProject adapter

Components need to learn the project and workspace of a bndlib backed project, for this the very first step for an integration is to provide an adapter that can transform an (Eclipse) IProject into a (bndlib) Project (from were the Workspace then can be derived), an example might look like this:

@Component
@AdapterTypes(adaptableClass = IProject.class, adapterNames = Project.class)
public class BndPluginAdapter implements IAdapterFactory {

  @Override
  public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
    if (adaptableObject instanceof IProject eclipseProject) {
      if (adapterType == Project.class) {
        //... here we need to determine if the project is managed by our tooling, e.g. it is a PDE, Bndtool, Maven, ... backed project
        if (/*... is relevant ... */) {
          // if that is the case, setup a Project that represent your tooling specific setup and return it
          Project bndProject = ... fetch or setup a project that maps to the given eclipse project...
          return adapterType.cast(bndProject);
        }
      }
    }
    return null;
  }

}

Available components

Beside some integration stuff (e.g. enable to discover bndlib plugins inside an OSGi runtime) it currently offers these components: