|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.qpid.client.util.BlockingWaiter<T>
public abstract class BlockingWaiter<T>
BlockingWaiter is a 'rendezvous' which delegates handling of incoming Objects to a listener implemented as a sub-class of this and hands off the process or error to a consumer. The producer of the event does not have to wait for the consumer to take the event, so this differs from a 'rendezvous' in that sense.
BlockingWaiters are used to coordinate when waiting for an an event that expect a response. They are always used in a 'one-shot' manner, that is, to recieve just one response. Usually the caller has to register them as method listeners with an event dispatcher and remember to de-register them (in a finally block) once they have been completed. Theprocess(T)
must return true on any incoming method that it handles. This indicates to
this listeners that the object just processed ends the waiting process.
Errors from the producer are rethrown to the consumer.
Responsibilities | Collaborations |
---|---|
Accept generic objects as events for processing via process(T) . | |
Delegate handling and undserstanding of the object to a concrete implementation. | |
Block until process(T) determines that waiting is no longer required | |
Propagate the most recent exception to the consumer. |
Field Summary | |
---|---|
protected Object |
_doneObject
Holds the incomming Object. |
Constructor Summary | |
---|---|
BlockingWaiter()
|
Method Summary | |
---|---|
Object |
block(long timeout)
Blocks until an object is received that is handled by process, or the specified timeout has passed. |
void |
close()
Close this Waiter so that no more errors are processed. |
void |
error(Exception e)
This is a callback, called when an error has occured that should interupt any waiter. |
abstract boolean |
process(T object)
Delegates processing of the incomming object to the handler. |
boolean |
received(T object)
An Object has been received and should be processed to see if our wait condition has been reached. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Object _doneObject
Constructor Detail |
---|
public BlockingWaiter()
Method Detail |
---|
public abstract boolean process(T object)
object
- The object to process.
public boolean received(T object)
object
- The object received.
public Object block(long timeout) throws org.apache.qpid.AMQException, FailoverException
timeout
- The timeout in milliseconds.
org.apache.qpid.AMQException
FailoverException
public void error(Exception e)
e
- The exception being propogated.public void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |