lime
Class LocalizedReaction

java.lang.Object
  extended bylime.Reaction
      extended bylime.LocalizedReaction
All Implemented Interfaces:
java.io.Serializable

public class LocalizedReaction
extends Reaction

Specifies reactions that are concerned only with a localized projection of the shared tuple space. The projection is defined using a pair current/destination location, similar to other tuple space operations such as inp. Basically, in order for the reaction to fire, not only the tuple space must contain a tuple that matches the template specified by the reaction, but the current and destination locations of the tuple must match as well.

    ts.addReaction(new LocalizedReaction(new HostLocation(
                          new LimeServerID(InetAddress.getLocalHost(),
                                           agent.getMgr().getPort())),
                   new AgentLocation(agent.getMgr().getID()),
                   new MyReactionListener(),
                   template, Reaction.ONCE);
    
that specifies a reaction whose current location is bound to the host where the statement is executed, by determining the local host, e.g., myHost.

The UNSPECIFIED wild card location is allowed only for the destination location. If UNSPECIFIED is passed as the current parameter, an exception is raised in the constructor of LocalizedReaction. NOTE: These semantics have changed since the original release.

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

Field Summary
 
Fields inherited from class lime.Reaction
ONCE, ONCEPERTUPLE, pendUponListener
 
Constructor Summary
(package private) LocalizedReaction(lights.interfaces.ITuple template, ReactionListener listener, short mode)
          Package accessible constructor to make a localized reaction.
  LocalizedReaction(LimeTemplate template, ReactionListener listener, short mode)
          Create the reaction, by specifying location information.
 
Methods inherited from class lime.Reaction
getCurrentLocation, getDestinationLocation, getLimifiedTemplate, getListener, getMode, getTemplate, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalizedReaction

public LocalizedReaction(LimeTemplate template,
                         ReactionListener listener,
                         short mode)
                  throws java.lang.IllegalArgumentException
Create the reaction, by specifying location information.

Parameters:
template - tuples in the shared tuple space that match this template will trigger execution of the reaction, i.e., invocation of the listener.
listener - the reaction listener, which specifies the computation to take place when the reaction is fired.
mode - the reaction mode (see Reaction).

LocalizedReaction

LocalizedReaction(lights.interfaces.ITuple template,
                  ReactionListener listener,
                  short mode)
            throws lights.interfaces.TupleSpaceException
Package accessible constructor to make a localized reaction.

Parameters:
template - a limeified tuple to match
listener - the listener code to run
mode - node of the reaction