Java Reference
In-Depth Information
jEdit
JARClassLoader
PluginJAR
jEdit
JARClassLoader
PluginJAR
Common plugin API
OSGi mapping layer
Figure 6.10 Extracting a
common jEdit plugin API
How about being able to register OSG i bundles as jEdit plugins? This is a stepping
stone to using services, because you need a bundle context to access OSG i services.
The main jEdit class provides two static methods to add and remove plugin JAR files:
public static void addPluginJAR(String path);
public static void removePluginJAR(PluginJAR jar, boolean exit);
Following the extender pattern introduced in section 3.4, let's use a bundle tracker to
look for potential jEdit plugins. The code in the following listing uses a tracker to add
and remove jEdit plugin bundles as they come and go.
Listing 6.4 Using the extender pattern to install jEdit plugins
package org.foo.jedit.extender;
import java.io.File;
import org.gjt.sp.jedit.*;
import org.osgi.framework.*;
public class Activator implements BundleActivator {
BundleTracker pluginTracker;
public void start(final BundleContext ctx) {
pluginTracker = new BundleTracker(ctx) {
actions.xml B
Looks for
public void addedBundle(Bundle bundle) {
String path = getBundlePath(bundle);
if (path != null && bundle.getResource("actions.xml") != null) {
jEdit.addPluginJAR(path);
}
}
Search WWH ::




Custom Search