pluginCore
Class CoreHandler

java.lang.Object
  extended by pluginCore.CoreHandler

public class CoreHandler
extends Object

The core handler provides a controlled interface that is handed to the plug-ins to allow them communication with the main core. All calls that are made by plug-ins are run through the CoreHandeler.


Field Summary
private  Plugin myPlugin
          The plug-in that this CoreHandeler is associated with.
private  PluginCore runningCore
          The pointer to the active PluginCore.
 
Constructor Summary
CoreHandler(PluginCore coreIn, Plugin plugIn)
          Initializes the CoreHandeler
 
Method Summary
 boolean isLocked(int id)
          Checks if a plugin has a unstable lock held on it.
 String[] listLoadedPlugins()
          Lists the plug-ins that are currently loaded in the system.
 int loadPlugin(String plugin)
          Loads a new plug-in into the system and starts its thread running.
 int loadPlugin(String plugin, Object[] state)
          Loads a new plug-in into the system and initalizes it with the data from a previous plugin, that is contained in the stateIn array.
 int pluginIDRequest(String plugin)
          Gets the Id of a plug-in, this ID can then be used to send messages to that plug-in.
 int postMessage(Message messIn)
          Requests that the core send the message 'messIn' to the plug-in with the same Id as the destID field in the Message object.
 Object[] savePlugin(int pluginId)
           
 void shutdown()
          Stops the system running, first calls the 'shutdown()' call for all loaded plug-ins then calls a join() on them before finally 'exiting itself.
 boolean unloadPlugin(int plugId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

runningCore

private PluginCore runningCore
The pointer to the active PluginCore.


myPlugin

private Plugin myPlugin
The plug-in that this CoreHandeler is associated with.

Constructor Detail

CoreHandler

public CoreHandler(PluginCore coreIn,
                   Plugin plugIn)
Initializes the CoreHandeler

Parameters:
coreIn - A pointer to the running core.
Method Detail

isLocked

public boolean isLocked(int id)
Checks if a plugin has a unstable lock held on it.

Parameters:
id - The id of the plugin to ckeck.
Returns:
True if the plugin is locked, false if it is unlocked.

pluginIDRequest

public int pluginIDRequest(String plugin)
Gets the Id of a plug-in, this ID can then be used to send messages to that plug-in. If the plug-in is not already loaded then the system will attempt to load it, then return the ID.

Parameters:
plugin - The name of the plugin you are looking for, the PluginCore checks the field Plug-in.pluginName.
Returns:
The Id of the plug-in, or a -1 on failure.

loadPlugin

public int loadPlugin(String plugin)
Loads a new plug-in into the system and starts its thread running.

Parameters:
plugin - The full name of the object that you wish to load into the system.
Returns:
The plugin's Id is returned if successful and -1 is returned on failure.

loadPlugin

public int loadPlugin(String plugin,
                      Object[] state)
Loads a new plug-in into the system and initalizes it with the data from a previous plugin, that is contained in the stateIn array.

Parameters:
pluginName - The full name of the object that you wish to load into the system.
Returns:
The plugin's Id is returned if successful and -1 is returned on failure.

unloadPlugin

public boolean unloadPlugin(int plugId)

shutdown

public void shutdown()
Stops the system running, first calls the 'shutdown()' call for all loaded plug-ins then calls a join() on them before finally 'exiting itself.


listLoadedPlugins

public String[] listLoadedPlugins()
Lists the plug-ins that are currently loaded in the system.

Returns:
A list of loaded plug-ins with newlines separating them.

savePlugin

public Object[] savePlugin(int pluginId)

postMessage

public int postMessage(Message messIn)
Requests that the core send the message 'messIn' to the plug-in with the same Id as the destID field in the Message object.

Parameters:
messIn - The message to be sent.
Returns:
Returns 1 on success and 0 on failure.