DAVINSPECTOR PLUGIN-DEVELOPMENT HOWTO



HOWTO TO WRITE PLUGINS FOR DAVINSPECTOR



18.04.2008 - Markus Litz
DLR (German Aerospace Center)
Simulation and Software Technology

This is a updated brief explanation about writing plugins for DAVInspector. If you are just looking for a user guide please take a look at the DAVInspector website at <http://davinspector.sourceforge.net/>. This explains what this version of DAVInspector is and how you could add new features to DAVInspector without knowledge of the core program. Just some experiences in java programming are needed.


Contents

What is DAVInspector?

DAVInpector is a tool for debugging and monitoring HTTP and WebDAV capable applications. It is mainly written to help developers creating HTTP/WebDAV clients or servers, but could also be used by sysadmins. The open plugin technology makes it possible that in future other network protocols will be support too.

DAVInspector is developed by employees of the the institution "Simulation and Software Technology" (SISTEC) at the German Aerospace Center DLR.

We are happy about any support for this project - for example you might participate as a developer, bug reporter or simply by telling us your needs. Just visit our forums or join our mailing-lists on Sourceforge.

What do I need?

You need :

To build or run DAVInspector you need a Java 2 Runtime Environment (JRE) with a version number 1.5.0 and higher. You can download the JRE for a number of platforms from <http://java.sun.com>. If you want to build DAVInspector you additionally need a recent version of the Jakarta Ant build tool. You can download Ant from <http://jakarta.apache.org>.

Writing Plugins

There are 2 types of plugins. ViewPlugins and EditPlugins. The ViewPlugins only shows the transfert data and gives you the possibility to change the way how to display these data, e.g. highling. Through EditPlugins DAVInspector gives you the capability to change the transfered data like body or header informations. The two types of plugins are represented by the two interfaces IViewPlugin and IEditPlugin. Your own plugin has to implement one of these interfaces.

Constructor

Since the plugins are loaded dynamically, there is no constructor we can use to set things up. Instead each plugin has to implement the method init(), which acts like a constructor. For example the init() of the ExampleView plugin:

public void init(PluginManager pluginManager, PluginDirection direction) {
        myPlugInDirection = direction;
        if (myJScrollPane == null) {
            myJTextPane = new JTextPane();
            myJScrollPane = new JScrollPane();
            myJScrollPane.setViewportView(myJTextPane);
        }
        myJTextPane.setText("");
        Util.setUIDesign();
    }

Naming conventions

To write your own plugin you have to follow some naming conventions. Otherwise DAVInspector is not able to load your plugin. The main class of your plugin has to belong to a package de.dlr.davinspector.plugins.<Main Class>.
So, let's assume to write a plugin named ExampleViewPlugin. The first few lines of code have to look like this:

package de.dlr.davinspector.plugins.exampleviewplugin;
 
import de.dlr.davinspector.common.Util;
import de.dlr.davinspector.history.AMessage;
import de.dlr.davinspector.plugin.IViewPlugin;
import de.dlr.davinspector.plugin.PluginManager;

public class ExampleViewPlugin implements IViewPlugin {
...
}

If you think, you are ready to test your plugin, create a jar file of it named like the main class. In our example that would be ExampleViewPlugin.jar. Copy it to the plugin directory of DAVInspector and start DAVInspector. Now you should see you plugin in the plugin-configuration window.

GUI

Ne gui is wat feines...
Muffi-Schlumpf sagt: ``Ich hasse GUI!''

Internationalization (I18N)

To make your plugin multilingual, you have to .....

Logging

You should use the Logging system of DAVInspector to log debug and error messages. All you have to do is, to create a logging object for each class:

public class ExampleViewPlugin implements IViewPlugin {
    /** Logger, Apache log4j. */
    private static Logger myLogger = Logger.getLogger(ExampleViewPlugin.class);
}

Then you can use the five logging methods debug(), info(), warn(), error() and fatal()
For example: logger.debug("This is a debug message");
All messages should appear on stdout / the logging file.

Troubleshooting

If your plugin doesn't load and java is saying something about invalid class version numbers or something like that, make sure, that you have compiled DAVInspector and your plugin with the same JDK version. You could also write to the DAVInspector development mailinglist [1].

Conclusion

The DAVInspector development has just started, so please support us with potential error descriptions. We hope DAVInspector and this HOWTO could help your development environment.

Call for participation

DAVInspector is open source project under Apache2 License. So anybody is welcome to the project. Please join our development mailing list : <davinspector-developers@lists.sourceforge.net> [1], if you have interest.

Bibliography

1
DAVInspector Development mailing list - https://lists.sourceforge.net/lists/listinfo/davinspector-developers


Markus Litz 2008-04-18