All Packages Class Hierarchy This Package Previous Next Index
Class oplan.acp3.KqmlWatcher
java.lang.Object
|
+----oplan.acp3.KqmlWatcher
- public class KqmlWatcher
- extends Object
A KqmlWatcher is used to look for significant Kqml messages and
tell an implementation of WatcherListener about them.
Using a KqmlWatcher typically involves four steps:
KqmlWatcher watcher = new KqmlWatcher();
watcher.setListener(someWatcherListener);
watcher.init();
watcher.watcherMainLoop();
The listener can also be provided as an argument to new KqmlWatcher.
init() creates a Kqml agent called "ACP3" and creates message handlers
for the Kqml performatives ACP3 expects to receive. It also creates a
log file. The call to watcher.init() should be omitted in cases when
it is not intended for ACP3 to receive Kqml messages.
Assignment to KqmlWatcher.kqmlAgentName before init() is called
will change the name used when registering the Kqml agent.
watcherMainLoop() loops forever waiting for messages and interpreting
them when they arrive. It should be called only if init() was called
earlier.
- See Also:
- WatcherListener, MessageWatcher
-
creationDate
-
-
interp
-
-
kqmlAgent
-
-
kqmlAgentName
- Our name as a Kqml agent
-
kqmlEvents
-
-
listener
-
-
logDirectoryName
-
-
logFileName
-
-
logWriter
-
-
KqmlWatcher(WatcherListener)
- Create a KqmlWatcher connected to a WatcherListener.
-
analyseMessage(Message)
- Performs the actual message analysis.
-
createLogFile()
- Create a file for recording the messages we receive.
-
fatalException(Exception)
- fatalException is called when an exception indicates that something
that must happen has failed, and there isn't anything in the system
that would enable it to fix the problem and try again.
-
init()
- The init() method creates a KqmlAgent and then registers message
handlers for the Kqml performatives we care about.
-
interpret(KqmlEvent)
- A public interface to the Kqml message-interpretation code.
-
logMessage(Message)
- Record the message in our log file.
-
pleaseAnalyse(Message)
- Enqueues a Kqml Message for analysis in watcherMainLoop.
-
registerHandler(String, boolean)
-
-
setListener(WatcherListener)
- Change the WatcherListener that the KqmlWatcher tells of status changes.
-
shutdown()
- shutdown should be called before the system exits so that it can
call kqmlAgent.shutdown().
-
watcherMainLoop()
- Analyses messages enqueued by pleaseAnalyse.
Loops forever.
listener
public WatcherListener listener
kqmlAgent
public KqmlAgent kqmlAgent
interp
protected KqmlInterpreter interp
kqmlEvents
protected MessageQueue kqmlEvents
creationDate
protected Date creationDate
logDirectoryName
public String logDirectoryName
logFileName
public String logFileName
logWriter
public Writer logWriter
kqmlAgentName
protected static String kqmlAgentName
- Our name as a Kqml agent
KqmlWatcher
public KqmlWatcher(WatcherListener listener)
- Create a KqmlWatcher connected to a WatcherListener.
setListener
public void setListener(WatcherListener listener)
- Change the WatcherListener that the KqmlWatcher tells of status changes.
init
public void init()
- The init() method creates a KqmlAgent and then registers message
handlers for the Kqml performatives we care about. It also creates
a log file. init() should not be called if there's no desire to
receive actual KQML messages. A KqmlWatcher may still be useful
in such cases, because there are other ways to give it messages
to interpret.
registerHandler
protected void registerHandler(String performative,
boolean analyse)
watcherMainLoop
public void watcherMainLoop()
- Analyses messages enqueued by pleaseAnalyse.
Loops forever.
pleaseAnalyse
public void pleaseAnalyse(Message msg)
- Enqueues a Kqml Message for analysis in watcherMainLoop.
analyseMessage
protected void analyseMessage(Message msg)
- Performs the actual message analysis.
interpret
public void interpret(KqmlEvent event)
- A public interface to the Kqml message-interpretation code.
createLogFile
protected void createLogFile() throws IOException
- Create a file for recording the messages we receive.
The file name is based on the date and time when createLogFile
was called and will be something like "acp3-log-18-mar-98-21:51:05".
logMessage
protected void logMessage(Message msg)
- Record the message in our log file.
shutdown
public void shutdown()
- shutdown should be called before the system exits so that it can
call kqmlAgent.shutdown(). The main program class should define a
shutdown method that calls our shutdown method, and ACP3.exit will
then cause the right things to happen. That is, we should have
something like: ACP3.exit --> main program class shutdown -->
KqmlWatcher shutdown --> KqmlAgent shutdown.
fatalException
static void fatalException(Exception e)
- fatalException is called when an exception indicates that something
that must happen has failed, and there isn't anything in the system
that would enable it to fix the problem and try again.
All Packages Class Hierarchy This Package Previous Next Index