lime.util.console
Class LimeConsoleListener

java.lang.Object
  |
  +--lime.util.console.LimeConsoleListener
All Implemented Interfaces:
java.util.EventListener, ReactionListener, java.io.Serializable

public class LimeConsoleListener
extends java.lang.Object
implements ReactionListener

Defines a reaction listener that can be used in combination with a LimeConsole object to display information about a given Lime tuple space.

Due to its close integration with the LimeConsole class, the definition of this listener is a little bit restrained. In particular, the reactsTo method of the ReactionListener cannot be overridden. Instead, programmers must override the method consoleActions with the desired behavior. This method gets called in the reactsTo method and thus is invoked by the system as part of the reaction listener when it fires. After execution of the consoleActions methods, the reactsTo methods performs some system operation on the console in order to refresh its contents. The implementation of consoleActions currently provided is the following:

public void consoleActions(ReactionEvent e) {
         provider.getConsole().display("Reacted to tuple " + 
                                       e.getEventTuple().toString() + 
                                       ".\n"); 
  }
  
Thus, it just prints the tuple the listener has reacted to. A reference to the Lime console object that can be used to display information is acquired by requesting it to a "console provider", that has beeen associated to the listener either at construction time or through the setter. The decoupling between the console object and the listener is needed since the former may change over time, typically due to agent migration.

Version:
1.0 alpha
Author:
Amy L. Murphy, Gian Pietro Picco
See Also:
LimeConsole, LimeTupleSpace, Serialized Form

Constructor Summary
LimeConsoleListener()
          Create a new listener.
LimeConsoleListener(IConsoleProvider p)
           
 
Method Summary
 IConsoleProvider getConsoleProvider()
          Return the LimeConsole object this listener is associated to.
 void reactsTo(ReactionEvent e)
          Displays a brief message on the LimeConsole associated with the listener, and prints the tuple that has been reacted to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LimeConsoleListener

public LimeConsoleListener()
Create a new listener.

LimeConsoleListener

public LimeConsoleListener(IConsoleProvider p)
Method Detail

getConsoleProvider

public IConsoleProvider getConsoleProvider()
Return the LimeConsole object this listener is associated to.

reactsTo

public void reactsTo(ReactionEvent e)
Displays a brief message on the LimeConsole associated with the listener, and prints the tuple that has been reacted to. Can be overridden by programmers, to provide an alternative display.
Specified by:
reactsTo in interface ReactionListener
Parameters:
e - the ReactionEvent the listener will react to.