Previous: Plugin Creator Next: Creating Map Plugin Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > Site Configuration > Plugins

7.4.1.1 Plugin Jar Files
Note: This page is intended for someone who wants to create an IDV plugin. A description of installing and managing plugins is here.

The IDV supports a plugin architecture that allows for the easy extension and addition of functionality. A plugin is most commonly a Java Jar file that contains a set of resource files (e.g., color tables) and/or Java class files. The plugins are stored on a local directory or could be loaded form a web site. The IDV processes the plugin Jar file at run time loading in the contained resources and code.

7.4.1.1.0 Basic Plugin
Lets suppose you have created a set of color tables and some Jython code that you want to make a plugin with. As described in the Site Configuration docs the IDV stores these user created files in <user home>/.metappps/DefaultIdv as colortables.xml and default.py.

To make these into a plugin, e.g., myplugin.jar, simply jar the the files (you need to get a Java SDK for this):

jar -cvf myplugin.jar colortables.xml default.py
Now this plugin can be distributed to others and loaded into their IDV environment.

So, you might ask how does the IDV recognize these files in the plugin and treat them appropriately? The IDV loads in a set of resources (e.g., color tables, Python libraries). Each resource type is identified by a regular expression as shown in the resource list. In our example above the file name colortables.xml matches the pattern for color table xml resources.

Now, what happens if you have some file whose name does not match a pattern? Say, you have a color table xml file called myspecialtables.xml that you want to include in a bundle. In that case you can add a .rbi file, as described here, that defines this file as a resource:

<?xml version="1.0" encoding="ISO-8859-1"?>
<resourcebundle>
  <resources name="idv.resource.colortables">
    <resource location="/myspecialtables.xml"/>
  </resources>
</resourcebundle>
This acts as a table of contents for the plugin. Make sure that the location is not relative. Note: Jar files can contain directory trees. e.g., /tables/myspecialtables.xml. In this case just have the location point to:
...
    <resource location="/tables/myspecialtables.xml"/>
...
7.4.1.1.1 Including Code
You can also include code that implements certain functionality by just including the Java .class files in the Jar. When you do this you need to include them like a normal class containing Jar file, i.e., the package structure of your code (e.g., edu.ucar.app.Test) needs to be reflected in the directory structure of the Plugin Jar file:
/edu/ucar/app/Test.class
For a single class file this is not necessarily required but if there are multiple class files that have interdependency among themselves then you will get into trouble if you don't follow this structure.

Now, what this code does can be anything and is best left up to the developer's guide.

 


Previous: Plugin Creator Next: Creating Map Plugin Table of contents Images Frames Unidata's Integrated Data Viewer > Miscellaneous > Site Configuration > Plugins