one.world.util
Class Synchronous.ResultHandler

java.lang.Object
  |
  +--one.world.util.AbstractHandler
        |
        +--one.world.util.Synchronous.ResultHandler
All Implemented Interfaces:
EventHandler, Serializable
Enclosing class:
Synchronous

public static class Synchronous.ResultHandler
extends AbstractHandler

Implementation of the result handler for synchronous event handler invocations. Note that result handlers are not serializable.

See Also:
Serialized Form

Constructor Summary
Synchronous.ResultHandler()
          Create a new result handler.
 
Method Summary
 Event getResult()
          Get the result for this result handler.
 Event getResult(long timeout)
          Get the result for this result handler.
protected  boolean handle1(Event e)
          Handle the specified event.
 void reset()
          Reset this result handler.
 
Methods inherited from class one.world.util.AbstractHandler
handle, isNotValid, respond, respond, respond, respond, respond, respond
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Synchronous.ResultHandler

public Synchronous.ResultHandler()
Create a new result handler.
Method Detail

handle1

protected boolean handle1(Event e)
Handle the specified event.
Overrides:
handle1 in class AbstractHandler
Following copied from class: one.world.util.AbstractHandler
Parameters:
e - The event to handle.
Returns:
true if the specified event was handled by this method.

getResult

public Event getResult()
Get the result for this result handler. This method times out after Constants.SYNCHRONOUS_TIMEOUT milliseconds.
Returns:
The resulting event.
Throws:
TimeOutException - Signals that the synchronous invocation has timed out without receiving a result.

getResult

public Event getResult(long timeout)
Get the result for this result handler. This method times out after the specified duration.
Parameters:
timeout - The timeout for waiting for the result.
Returns:
The resulting event.
Throws:
IllegalArgumentException - Signals that timeout is negative.
TimeOutException - Signals that the synchronous invocation has timed out without receiving a result.

reset

public void reset()
Reset this result handler. This method resets this result handler so that it can be re-used for another synchronous invocation. This method should only be called if no thread is waiting for a result on this result handler.


(C) Copyright 2001 UW CSE