|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.Thread
|
+--irssibot.modules.AbstractModule
Base class for all modules for IrssiBot. Implements some basic functionality common for all modules. The module acts as a 'consumer' for the bot core, who 'produces' IrcMessage objects to the module's processing queue.
| Field Summary | |
private boolean |
alive
Indicates whether the module thread should continue executing its run() loop. |
private java.lang.Throwable |
consumerException
A state variable indicating whether the module is executing ok. |
private IrcMessage |
consumerMessage
The message causing the consumer exception. |
private java.util.Vector |
messageQueue
Vector containing MessageData objects waiting for processing. |
private java.lang.Object |
processLock
A lock object used for producer-consumer synchronization |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
protected |
AbstractModule(java.lang.String name)
Constructs with named thread. |
| Method Summary | |
void |
addMessage(IrcMessage message,
ServerConnection serverConnection)
Appends the new IrcMessage+ServerConnection pair to the end of the message queue. |
private void |
fetchNextMessage()
Fetches next message in queue and pass it on to processMessage(). |
abstract java.lang.String |
getModuleInfo()
Module should return a descriptive info string containing at least module's name and version. |
java.util.Properties |
getState()
Gets module's state as a Properties object. |
void |
killModule()
Kills module thread. |
boolean |
onLoad(java.util.Properties state,
Core core)
Called upon loading the module. |
void |
onUnload()
Called upon unloading the module. |
protected abstract void |
processMessage(IrcMessage message,
ServerConnection serverConnection)
Processes messages as they come in. |
void |
run()
Thread loop. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private final java.util.Vector messageQueue
private final java.lang.Object processLock
private boolean alive
private java.lang.Throwable consumerException
addMessage(IrcMessage,ServerConnection)private IrcMessage consumerMessage
| Constructor Detail |
protected AbstractModule(java.lang.String name)
name - name for thread| Method Detail |
public abstract java.lang.String getModuleInfo()
public java.util.Properties getState()
public boolean onLoad(java.util.Properties state,
Core core)
state - the initial state of module as an Properties object, or
null if no state was saved for module.core - a Core instance. this can be used to initialize module if
no state was retrieved.
Corepublic void onUnload()
public final void addMessage(IrcMessage message,
ServerConnection serverConnection)
throws java.lang.Throwable
message - the IrcMessage to append to the message queue
java.lang.Exception - thrown if an exception was thrown by the
consumer thread in processMessage().
java.lang.ThrowableprocessMessage(IrcMessage,ServerConnection)private final void fetchNextMessage()
#processMessage(IrcMessage)
protected abstract void processMessage(IrcMessage message,
ServerConnection serverConnection)
message - the incoming IrcMessagepublic void killModule()
public final void run()
run in interface java.lang.Runnablerun in class java.lang.Thread
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||