PluginCore at Sourceforge

The CoreHandler

The CoreHandler object provides a proxy interface to the PluginCore for each plug-in. It allows direct calls to be made to the PluginCore from each plugin with out exposing the core itself or even the full set of calls that can be made to the core. For increased security the CoreHandler can be subclassed to add or remove functionality. The basic CoreHandler has a small amount of sanity checking on Message passing, it will check to make sure that the plug-in that is sending the message is actually putting the correct source address on the message but much more can be done in the proxy. These are the methods that are provided in the basic CoreHandler.


The PluginCore


public int postMessage( Message messIn )

This call sends a message to the PluginCore to get delivered to another plug-in, it will look up the plug-in based on the integer address that is stored in the destination variable in the message.


public int pluginIDRequest( String plugin )

Based on the name provided this will request that the core find a plug-in and, if it is loaded, return the address of the first instance of this plug-in. If there are multiple instances of a plugin running this will not be capable of differentiating between, in that case the program should keep track of the ids as they are returned from the loadPlugin call. If there is no plug-in this will return a -1, else the id of the plug-in. The name of the plugin is the name that a plug-in stores the the pluginName variable.

public int loadPlugin( String plugin )

This will request that the PluginCore load a plug-in, the .class file must be in the CLASSPATH, and must be in the proper directory structure based on package. The plug-in name is the fully qualified name of the object, such as "ipMedia.Client.plugins.ShowBuffer " if it is loadable the plug-in is loaded into the system and the id of the plug-in is returned, if it cannot be loaded then a -1 is returned.


public int loadPlugin( String plugin, Object[] state )

This call will load a plug-in into the core, and set the plug-ins state based on the object array. The object array is provided by calling the savePlugin call. This is used to swap plug-ins in and out, the new plug-in will have the same address of the plug-in that the state was pulled from.


public boolean unloadPlugin( int plugId )

When called this method will attempt to remove the plug-in identified by the id from the PluginCore. The shutdown() method will be called on the plug-in, and then it will have a join() called on the thread. Once this is complete the plug-in will be nulled and left for garbage collection.


public void shutdown()

This shuts down the entire PluginCore, which will call the shutdown() on every loaded plug-in and then exit.


public String[] listLoadedPlugins()

This returns a string array containing the name of each plug-in loaded, the plug-in names are set by the pluginName variable.


public Object[] savePlugin( int pluginId )

savePlugin will have the PluginCore look up the plugin by id then call the savePluginState() method on it. The object array returned contains the local variables that contain the plugins state.