under construction

Introduction

Plugins
OSGi
Extension points

IGB has several "extension points" designed specifically for plugins. These are interfaces or abstract classes that
are implemented or extended by plugin versions. Usually the Activator for the plugin will register the plugin as a
service in the start() method:
bundleContext.registerService(<extension point>.class.getName(), <plugin implementation>, new Properties());

The current extension points are:

Developing IGB bundles

IGB bundles are OSGi compatible, so they should have an Activator and they must have a MANIFEST.MF file that is found in the META-INF directory. These are compiled and jarred with all required classes, jars, and resources. The resulting jar is the bundle. This can then be uploaded to the bundle repository. At that point, any one can use the bundle with IGB. IGB uses the Apache Felix OSGi implementation, but this could change, so no Felix specific code should be used. In the Activator class, there is a start() and stop() method. This is where you want to put all the code to start and stop the bundle.

In the MANIFEST.MF file, there are several headers that need to be specified - fill in parenthesis below:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: (name of bundle)
Bundle-SymbolicName: (name of bundle)
Bundle-Version: (bundle version, you can use 1.0.0 to start)
Bundle-Activator: (activator class name, including package)
Bundle-ActivationPolicy: lazy
Bundle-Vendor: (your company)
Bundle-DocURL: (URL of bundle documentation)
Import-Package: (list all external packages required by the bundle)
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: (put the class path within the bundle itself, e.g.: ., resources/, lib/xyz.jar)
Bundle-Description: (description of bundle)
Require-Bundle: (list all bundles required by this bundle)

If you look at the Plug-ins tab, you will see the Bundle-SymbolicName under the Name column, the Bundle-Description under the Description column, and the Bundle-Version under the Version column. If the Bundle-DocURL is there, the Name cell will have a blue info icon that links to this URL.

Sample plug-in

  1. to create a plugin, you will create (at least) two files, the MANIFEST.MF file and the Activator
  2. we will create a bundle that adds a new graph function
  3. create the following MANIFEST.MF file:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyTransformer
Bundle-SymbolicName: MyTransformer
Bundle-Version: 1.0.0
Bundle-Activator: mypackage.MyActivator
Import-Package: com.affymetrix.genometryImpl.util,
 org.osgi.framework

(note - there are spaces at the beginning of the extension lines, and a blank line at the end)

  1. Now, create the Activator, mypackage.MyActivator.java
package mypackage;
import java.util.Properties;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import com.affymetrix.genometryImpl.util.FloatTransformer;

public class MyActivator implements BundleActivator {
    private BundleContext bundleContext;
    private ServiceRegistration serviceRegistration;
    protected BundleContext getContext() {
        return bundleContext;
    }
    public void start(BundleContext _bundleContext) throws Exception {
        bundleContext = _bundleContext;
        serviceRegistration =
            bundleContext.registerService(FloatTransformer.class.getName(),
            new MyTransformer(), new Properties());
    }
    public void stop(BundleContext _bundleContext) throws Exception {
        if (serviceRegistration != null) {
            serviceRegistration.unregister();
        }
        bundleContext = null;
    }
}
  1. And create the Transformer, mypackage.MyTransformer.java
package mypackage;
import com.affymetrix.genometryImpl.util.FloatTransformer;
public class MyTransformer implements FloatTransformer {
    final String paramPrompt;
    final String name;
    public MyTransformer() {
        super();
        paramPrompt = null;
        name = "MyTransformer";
    }
    public String getParamPrompt() { return null; }
    public String getName() {
        return name;
    }
    public String getDisplay() {
        return name;
    }
    public float transform(float x) {
        return x; // boring, put your own math function here, return 1.0/x; or return 3*x*x*x - 2*x*x +8*x - 6;
    }
    public boolean setParameter(String s) {
        return true;
    }
}
  1. Now, compile and jar these files into MyTransformer.jar (the jar command has a -m option for the manifest file).
  2. At this point, you want to put your jar into a web server using OBR (see above).
  3. this will create a repository.xml file listing all the bundles and their requirements.
  4. make sure the repository.xml file and the bundles directory are accessible to the web server.
  5. in IGB, open the File>Preferences page, Plugin Repositories tab
  6. click the Add ... button at the bottom
  7. enter the web server URL for the directory that has the repositories.xml file that you created - you can use whatever you want for the name.
  8. Click the "Add Server" button
  9. close the Preferences page.
  10. Open the Plugins tab
  11. you should see your bundle in the table, click on the install checkbox.
  12. Once you have installed your bundle, select a graph track on the main view, and open the Graph Adjuster tab. Now if you click on the Transformation drop down, you will see MyTransformer in the list. Select it and click the Go button, and you will see a new track using your bundle.

To create plug-ins using eclipse - a Quick-Start Guide

Eclipse (http://www.eclipse.org) makes it a lot easier to develop bundles. You can create a new project
as a plug in project, and it will give you wizards, etc. for development. see:http://www.vogella.de/articles/OSGi/article.html
(using eclipse Helios)

  1. Check out IGB from https://genoviz.svn.sourceforge.net/svnroot/genoviz/trunk into a new directory - we will refer to the project directory below as IGB_HOME.
  2. Open a command prompt in IGB_HOME, and do an "ant clean" and "ant jar"
  3. Make sure Eclipse is displaying the Project Explorer Tab. (If not, click View>Show View>Project Explorer.)
  4. In Eclipse, Project Explorer, right click the IGB project and select "refresh."
  5. In Eclipse, Project Explorer, right click on open space, and select "Import..." > "Plug-ins and Fragments" under "Plug-in Development", click the "Next >" button
    1. under "Import From", select "Directory:"
    2. under "Plug-ins and Fragments to Import" select "Select from all plug-ins and Fragments"
    3. under "Import As" select "Binary Projects"
    4. for "Directory:", click the "Browse..." button and select the IGB_HOME/bundles, click the "OK" button
    5. click the "Next >" button
    6. under "Plug-ins and Fragments Found:", select affx_fusion, colt, freehep, image4j, jlfgr, picard, and sam
    7. click the "Add -->" button to add these all to "Plug-ins and Fragments to Import:", click the "Finish" button
    8. Ann's note: The user must have already installed the Eclipse Plug-in Development Environment, under "General" in the Help>Install New Software window.
  6. Do the following for the directories under IGB_HOME, genometryImpl, common, genoviz_sdk, igb, plugins/igb_service, plugins/window_service

Sample plug-in using eclipse

  1. In the Project Explorer - blank area, right-click
  2. Under the new HelloWorld project, find the META-INF directory, and open the MANIFEST.MF file by double-clicking on it.
  3. Click on the "Dependencies" tab,
  4. Right click on the blank area at the top, next to "Dependencies" and
  5. Open the Activator.java file under src/helloworld
  6. Save the file
  7. In the Project Explorer
  8. The HelloWorld_1.0.0.jar file will be in the plugins directory under the directory the you specified. This is your bundle
  9. In the plugins directory, from the command line run
  10. Now, if you can access your plugins directory from a local web server, you can open up the Plug ins tab in IGB
  11. You should now see your Hello World plugin.
  12. Congratulations!

To create plug-ins using NetBeans - a Quick-Start Guide

Is this possible? Easy?