org.apache.qpid.client.state
Class StateWaiter

java.lang.Object
  extended by org.apache.qpid.client.util.BlockingWaiter<AMQState>
      extended by org.apache.qpid.client.state.StateWaiter

public class StateWaiter
extends BlockingWaiter<AMQState>

This is an implementation of the BlockingWaiter to provide error handing and a waiting mechanism for state changes. On construction the current state and a set of States to await for is provided. When await() is called the state at constuction is compared against the awaitStates. If the state at construction is a desired state then await() returns immediately. Otherwise it will block for the set timeout for a desired state to be achieved. The state changes are notified via the process(org.apache.qpid.client.state.AMQState) method. Any notified error is handled by the BlockingWaiter and thrown from the BlockingWaiter.block(long) method.


Field Summary
(package private)  Set<AMQState> _awaitStates
           
 
Fields inherited from class org.apache.qpid.client.util.BlockingWaiter
_doneObject
 
Constructor Summary
StateWaiter(AMQStateManager stateManager, AMQState currentState, Set<AMQState> awaitStates)
           
 
Method Summary
 AMQState await()
          Await for the requried State to be achieved within the default timeout.
 AMQState await(long timeout)
          Await for the requried State to be achieved.
 boolean process(AMQState state)
          When the state is changed this StateWaiter is notified to process the change.
 
Methods inherited from class org.apache.qpid.client.util.BlockingWaiter
block, close, error, received
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_awaitStates

Set<AMQState> _awaitStates
Constructor Detail

StateWaiter

public StateWaiter(AMQStateManager stateManager,
                   AMQState currentState,
                   Set<AMQState> awaitStates)
Parameters:
stateManager - The StateManager
currentState -
awaitStates -
Method Detail

process

public boolean process(AMQState state)
When the state is changed this StateWaiter is notified to process the change.

Specified by:
process in class BlockingWaiter<AMQState>
Parameters:
state - The new state that has been achieved.
Returns:

await

public AMQState await()
               throws org.apache.qpid.AMQException
Await for the requried State to be achieved within the default timeout.

Returns:
The achieved state that was requested.
Throws:
org.apache.qpid.AMQException - The exception that prevented the required state from being achived.

await

public AMQState await(long timeout)
               throws org.apache.qpid.AMQException
Await for the requried State to be achieved. It is the responsibility of this class to remove the waiter from the StateManager

Parameters:
timeout - The time in milliseconds to wait for any of the states to be achived.
Returns:
The achieved state that was requested.
Throws:
org.apache.qpid.AMQException - The exception that prevented the required state from being achived.


Licensed to the Apache Software Foundation