|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectpluginCore.PluginCore
public class PluginCore
The PluginCore is the main object in the plug-in architecture. It handles the plug-ins, starting, stopping, and message passing among them. To run: myComputer$ java PluginCore pluginName
Nested Class Summary | |
---|---|
private class |
PluginCore.PluginListElement
This is a single element that conains a plugin and a stable/unstable lock to controll acess to the plugin. |
private class |
PluginCore.PluginLoader
The implementation of ClassLoader that is used by the PluginCore. |
Field Summary | |
---|---|
private static boolean |
DEBUG
Turns on or off debugging output. |
private static boolean |
ERROR
Turns on or off error output. |
private static int |
LIST_GROWTH_SIZE
This is the number of elements that the list grows by each time it runs out of space. |
private static int |
LIST_STARTING_SIZE
This is the size of the PluginListElement list when the program starts. |
private int |
listSize
Expand defines the number of slots the pluginList starts with and by how many it grows when it is full |
private PluginCore.PluginListElement[] |
pluginList
This array contains the plug-ins that are currently loaded and running as their own threads |
private static String |
pluginPrefix
|
Constructor Summary | |
---|---|
PluginCore()
Initializes the PluginCore. |
Method Summary | |
---|---|
private void |
growList()
Increase the size of pluginList by the ammount LIST_GROWTH_SIZE. |
private int |
insertPlugin(Plugin newPlug)
Adds a plug-in into the list of active plug-ins. |
boolean |
isLocked(int id)
Checks if a plugin has a unstable lock held on it. |
private boolean |
isValidId(int plugId)
Checks to see if the plugin Id given is a valid address in the plugin list. |
String[] |
listLoadedPlugins()
Lists the plug-ins that are currently loaded in the system. |
private void |
loadAdmin()
|
int |
loadPlugin(String pluginName)
Loads a new plug-in into the system and starts its thread running. |
int |
loadPlugin(String pluginName,
Object[] stateIn)
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. |
static void |
main(String[] args)
The main function. |
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. |
protected void |
printDebug(String debugMsg)
This will print out an debug mesage identifying it as coming from the PluginCore. |
protected void |
printError(String errorMsg)
This will print out an error message identifying it as coming from the PluginCore. |
private static void |
printUseage()
Prints the useage command to the command line when poor input is given. |
Object[] |
savePlugin(int pluginId)
This will lock a plugin, stop it, reduce the state to a byte aray and return that array. |
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. |
private boolean |
shutdownAndJoinPlugin(int plugId)
This will shut down a plugin and join the thread. |
boolean |
unloadPlugin(int plugId)
Removes a plugin from the running PluginCore. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String pluginPrefix
private static final int LIST_STARTING_SIZE
private static final int LIST_GROWTH_SIZE
private static final boolean DEBUG
private static final boolean ERROR
private PluginCore.PluginListElement[] pluginList
private int listSize
Constructor Detail |
---|
public PluginCore()
Method Detail |
---|
private void growList()
public int loadPlugin(String pluginName)
pluginName
- The full name of the object that you wish to load into the
system.
public int loadPlugin(String pluginName, Object[] stateIn)
pluginName
- The full name of the object that you wish to load into the
system.stateIn
- The saved object array from the previous plugin.
private int insertPlugin(Plugin newPlug)
newPlug
- The plug-in to be added.
public int postMessage(Message messIn)
messIn
- The message to be sent.
public int pluginIDRequest(String plugin)
plugin
- The name of the plugin you are looking for, the PluginCore
checks the field Plugin.pluginName.
public boolean unloadPlugin(int plugId)
plugId
- The Id of the plugin to remove.
private boolean shutdownAndJoinPlugin(int plugId)
plugId
- This is the id of the plugin to shutdown.
public boolean isLocked(int id)
id
- The id of the plugin to ckeck.
public Object[] savePlugin(int pluginId)
pluginId
- The plugin to save.
private boolean isValidId(int plugId)
plugId
- The id to check.
public void shutdown()
public String[] listLoadedPlugins()
private void loadAdmin()
public static void main(String[] args)
args
- Handed to the program on load.private static void printUseage()
protected void printDebug(String debugMsg)
debugMsg
- This is the debug message.protected void printError(String errorMsg)
debugMsg
- This is the error message.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |