Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a readme that explains how to use the pde reusable osgi components #1334

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

laeubi
Copy link
Contributor

@laeubi laeubi commented Jul 11, 2024

This adds the following readme to explain the pde reusable osgi components

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:

@laeubi
Copy link
Contributor Author

laeubi commented Jul 11, 2024

CI won't matter here...

@laeubi laeubi merged commit 0c5e3c6 into eclipse-pde:master Jul 11, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant