Class AsyncResultHandler<T>
- java.lang.Object
-
- org.forgerock.openam.cts.impl.queue.AsyncResultHandler<T>
-
- Type Parameters:
T- the type of result handled
- All Implemented Interfaces:
ResultHandler<T,CoreTokenException>
public class AsyncResultHandler<T> extends Object implements ResultHandler<T,CoreTokenException>
AsyncResultHandler is an asynchronous implementation of the ResultHandler. It specifically is aware of the threading and timing concerns around asynchronous operations and mitigates that with the use of a BlockingQueue. The processed result is placed on the queue when available. At which point either the caller is already waiting, or can begin to wait for the result. The queue is sized to one to enforce the usage of this ResultHandler as being used only once.
-
-
Constructor Summary
Constructors Constructor Description AsyncResultHandler(QueueConfiguration config, Debug debug)Creates an instance of theResultHandlerwith a default queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetResults()Blocking call to wait for the results of processing.voidprocessError(Exception error)voidprocessResults(T result)
-
-
-
Constructor Detail
-
AsyncResultHandler
public AsyncResultHandler(QueueConfiguration config, Debug debug)
Creates an instance of theResultHandlerwith a default queue.- Parameters:
config- Non null configuration required for timeout configuration.debug- Non null.
-
-
Method Detail
-
getResults
public T getResults() throws CoreTokenException
Blocking call to wait for the results of processing.- Specified by:
getResultsin interfaceResultHandler<T,CoreTokenException>- Returns:
- A possibly null, result of type T.
- Throws:
CoreTokenException- if an error occurs while waiting for or retrieving the results
-
processResults
public void processResults(T result)
- Specified by:
processResultsin interfaceResultHandler<T,CoreTokenException>- Parameters:
result- The result to store in this ResultHandler. May be null.- Throws:
IllegalStateException- If there is already a value on the queue.
-
processError
public void processError(Exception error)
- Specified by:
processErrorin interfaceResultHandler<T,CoreTokenException>- Parameters:
error- The error to store in this result handler.
-
-