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.
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.
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;
}
}
Beside some integration stuff (e.g. enable to discover bndlib plugins inside an OSGi runtime) it currently offers these components:
- bnd templates
- osgi repositories view
- Formating of bnd files, quick fixes, completion proposals
- ... more to come ...