uk.ac.starlink.plastic
Class PlasticMonitor

java.lang.Object
  extended byuk.ac.starlink.plastic.PlasticMonitor
All Implemented Interfaces:
PlasticApplication, PlasticListener

public class PlasticMonitor
extends Object
implements PlasticApplication

Watches and reports on messages sent over a PLASTIC message bus. Designed principally to aid with debugging, both of PLASTIC infrastructure and of PLASTIC-aware applications.

This class is intended to be used standalone from its main(java.lang.String[]) method.

Since:
17 Feb 2006
Author:
Mark Taylor

Field Summary
 
Fields inherited from interface org.votech.plastic.PlasticListener
CURRENT_VERSION
 
Constructor Summary
PlasticMonitor(String name, boolean multiclient, PrintStream logOut, PrintStream warnOut)
          Constructor.
 
Method Summary
 String getName()
          Returns the application generic name.
 URI[] getSupportedMessages()
          Returns the messages which the application will support.
static void main(String[] args)
          Starts a monitor of the PLASTIC message bus which logs message descriptions to standard output.
 Object perform(URI sender, URI message, List args)
          Request that the application perform an action based on a message.
 void setHub(PlasticHubListener hub)
          Sets the hub this monitor is listening to.
 void setListModel(uk.ac.starlink.plastic.ApplicationListModel listModel)
          Sets a list model this monitor should keep up to date.
static String stringify(Object value)
          Stringifies an object for logging purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlasticMonitor

public PlasticMonitor(String name,
                      boolean multiclient,
                      PrintStream logOut,
                      PrintStream warnOut)
Constructor.

Parameters:
name - application name
multiclient - true if you want it to attempt to implement all known messages
logOut - logging output stream
warnOut - warning output stream
Method Detail

getName

public String getName()
Description copied from interface: PlasticApplication
Returns the application generic name.

Specified by:
getName in interface PlasticApplication
Returns:
name

getSupportedMessages

public URI[] getSupportedMessages()
Description copied from interface: PlasticApplication
Returns the messages which the application will support. An empty array means all messages.

Specified by:
getSupportedMessages in interface PlasticApplication
Returns:
supported message IDs

perform

public Object perform(URI sender,
                      URI message,
                      List args)
Description copied from interface: PlasticListener
Request that the application perform an action based on a message.

Specified by:
perform in interface PlasticListener
Parameters:
sender - the ID of the originating application.
message - the URI representing the action.
args - any arguments to pass.
Returns:
any return value of the action.
See Also:
http://plastic.sourceforge.net

setHub

public void setHub(PlasticHubListener hub)
Sets the hub this monitor is listening to.

Parameters:
hub - hub

setListModel

public void setListModel(uk.ac.starlink.plastic.ApplicationListModel listModel)
Sets a list model this monitor should keep up to date.

Parameters:
listModel - model of registered applications

stringify

public static String stringify(Object value)
Stringifies an object for logging purposes.

Parameters:
value - object to stringify
Returns:
human-readable version of value

main

public static void main(String[] args)
                 throws IOException
Starts a monitor of the PLASTIC message bus which logs message descriptions to standard output. A choice of Java-RMI and XML-RPC communication is offered.

Flags

-rmi
Use Java-RMI for communications (default)
-xmlrpc
Use XML-RPC for communications
-gui
Pops up a window monitoring currently registered applications
-verbose
Writes a log to standard output of all PLASTIC traffic
-warn
Writes a log to standard output of illegal or questionable conditions
-multi
Attempt to implement as many messages as possible (a dummy implementation is provided for every message know by the MessageDefinition class)
-name name
Supply application name which monitor will register under

Throws:
IOException


Copyright © 2006 \\ CLRC: Central Laboratory of the Research Councils. All Rights Reserved.