|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.estar.miat.MiatBaseImplementation
org.estar.miat.tcpip.MiatTCPIPControlServerThread
public class MiatTCPIPControlServerThread
My Intelligent Agent Toolkit. Module that runs a Socket server on a thread. Listens for incoming connections and spawns an instance of an inner thread to handle them. Reads input, and then finds an appropriate command implementor and invokes it.
Nested Class Summary | |
---|---|
protected class |
MiatTCPIPControlServerThread.ControlServerConnectionThread
Class implementing a connection from the control server socket. |
Field Summary | |
---|---|
protected java.util.Hashtable |
commandMap
A hashtable containing the mapping from command name's to their implementation classes. |
protected MiatLoggerInterface |
logger
Logger to use. |
protected int |
logLevel
The log level to supply to logger.log for this instance. |
protected int |
portNumber
The port the control server is running on. |
protected boolean |
quit
Set to true to stop the thread. |
static java.lang.String |
RCSID
Revision control system version id. |
protected java.net.ServerSocket |
serverSocket
The server socket. |
Fields inherited from class org.estar.miat.MiatBaseImplementation |
---|
id, interfaceRegistry, name |
Constructor Summary | |
---|---|
MiatTCPIPControlServerThread()
Default Constructor. |
Method Summary | |
---|---|
void |
addCommand(java.lang.String commandName,
MiatTCPIPControlServerCommandInterface commandImplementation)
Method called by MiatTCPIPControlServerCommandInterface implementor's initialise methods, to register themselves as a command that can be invoked when someone telnets into the TCP/IP control socket. |
protected java.lang.String |
doControlCommand(java.lang.String[] args)
This method is called when a command is read from a connection spawned from the control port. |
protected java.lang.String |
help()
Print out a help string. |
protected java.lang.String |
help(java.lang.String commandName)
Print out a help string for the specified command. |
void |
initialise()
Initialise method. |
void |
quit()
Quit the server socket. |
void |
run()
The run method. |
protected void |
startConnectionThread(java.net.Socket s)
Start a connection thread using the specified socket for communication. |
Methods inherited from class org.estar.miat.MiatBaseImplementation |
---|
getId, setId, setInterfaceRegistry, setName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.estar.miat.MiatInterface |
---|
getId, setId, setInterfaceRegistry, setName |
Field Detail |
---|
public static final java.lang.String RCSID
protected MiatLoggerInterface logger
MiatLoggerInterface
protected int logLevel
protected int portNumber
protected boolean quit
protected java.net.ServerSocket serverSocket
protected java.util.Hashtable commandMap
Constructor Detail |
---|
public MiatTCPIPControlServerThread()
commandMap
Method Detail |
---|
public void initialise() throws java.lang.Exception
initialise
in interface MiatInterface
initialise
in class MiatBaseImplementation
java.lang.Exception
- Thrown if an error occurs.logLevel
,
logger
,
portNumber
public void addCommand(java.lang.String commandName, MiatTCPIPControlServerCommandInterface commandImplementation) throws java.lang.Exception
addCommand
in interface MiatTCPIPControlServerThreadInterface
commandName
- The name of the command to register as.commandImplementation
- The implementation of that command.
java.lang.IllegalArgumentException
- Thrown if a command implementor is already registered for this command.
java.lang.Exception
commandMap
public void run()
run
in interface java.lang.Runnable
run
in interface MiatThreadInterface
serverSocket
,
quit
,
startConnectionThread(java.net.Socket)
public void quit() throws java.io.IOException
quit
in interface MiatTCPIPControlServerThreadInterface
java.io.IOException
- Can be thrown when closing the server socket.quit
,
serverSocket
protected java.lang.String help()
commandMap
,
help(java.lang.String)
protected java.lang.String help(java.lang.String commandName)
commandName
- The name of the command.commandMap
protected void startConnectionThread(java.net.Socket s)
s
- The socket to communicate over.MiatTCPIPControlServerThread.ControlServerConnectionThread
protected java.lang.String doControlCommand(java.lang.String[] args)
args
- The command arguments (the command itself is args[0]).
logLevel
,
commandMap
,
quit
,
help()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |