Search code examples
eclipse-pluginosgieclipse-rcpequinox

A bundle required by my plugin is not active


This post covers Eclipse Early start: How to ensure eclipse plugin has required bundles available?

This post covers configuring your plugin for "early start" after installed via p2 update: Require-Bundle and Import-Package versus feature.xml requires

This wiki entry covers Eclipse lazy start: http://wiki.eclipse.org/Lazy_Start_Bundles

In my case, I am loading a bundle (Apache Wink) that is required by my plugin bundle, and I need to ensure it is ACTIVE when my plugin is called. It is not enough that it present, what I mean is, I do not need to import any of its packages I just need it running so my plugin can do HTTP communication with it. I'm thinking of two solutions and would appreciate feedback on either, or welcome suggestions I haven't considered:

  1. Configure it for early start up so it starts when Eclipse starts (via extension). Since I am not author of the Wink Bundle I'm thinking of adding a fragment that implements the IStartup class. early start extension is generally frowned upon, so maybe:
  2. In my Activator, search for the bundle and activate if it is not already activated. problems?

Solution

  • From what you are describing, it sounds like you are creating plugins that people will be installing into an existing Eclipse instance. Also, you don't have control over how the Apache Wink plugin gets installed.

    This means that #1 would be tricky since the way to do this is to add a p2.inf file and add an auto-start property with a proper start level in it. If you were creating and bundling the apache wink plugin yourself, then this would be the way I'd recommend, but since you're not, I'd go with #2.

    All you need to do is something like this in your activator:

    Platform.getBundle("org.apache.foobar.wink").start();
    

    Simple, but a couple of caveats:

    1. Add a null check just in case the bundle is not installed.
    2. If the wink bundle takes a long time to start and initialize, you may want to start the wink bundle in a separate thread using a Job. But, then you must be sure to wait for the activation to be complete before you do work in your current bundle.