JBother Logo

Plugin Creation Documentation

All plugins are jar files. In the jar root, there needs to be a file called "plugin.properties" that contains information about the plugin. Here is an example for the SysTrayPlugin:
mainClass = com.valhalla.jbother.plugins.SystrayPlugin
description = Adds system tray icon for Linux
name = Systray Plugin
APIVersion = 91212
version = 0.0.2b
author = Yury Soldak
releaseDate = Jan 10, 2005
os = Linux
arch = i386
The main class needs to implement the Plugin interface (documentation here). If you want to listen for events, you also need to implement the PluginEventListener interface (documentation here). To listen for events, add the plugin to the plugin chain in the plugin's init() method. An exmaple is this:
 * Initializes plugin
 * @return true on success
public boolean init()
	PluginChain.addListener( this );
	com.valhalla.Logger.debug( "Systray plugin initiated" );
	return true;
All events are recieved by all plugins, so you just need to test for the type of event like so:
 * Handles StatusChangedEvent
 * @param event One of plugin events
public void handleEvent( PluginEvent event )
	if ( event instanceof StatusChangedEvent )
		// do whatever we need to when the status has changed
	else if( event instanceof ConnectEvent )
		connectionHandler( (ConnectEvent)event );
	else if( event instanceof ExitingEvent )
		exitingHandler( (ExitingEvent)event );
A list of available events that can be captured are here. I've just been adding events as needed, so if you need one that's not there, let me know and I'll write it.

The plugin must remove itself from the plugin chain and totally clean itself up in the unload() method. This makes it so that the plugins can be dynamically unloaded/loaded/upgraded.

Take a look at the api documentation for more information.