public class BlockingCallback extends Object implements Callback
To avoid late redundant calls to succeeded()
or failed(Throwable)
from
interfering with later reuses of this class, the callback context is used to hold pass a phase indicated
and only a single callback per phase is allowed.
A typical usage pattern is:
public class MyClass { BlockingCallback cb = new BlockingCallback(); public void blockingMethod(Object args) throws Exception { asyncMethod(args,cb); cb.block(); } publicvoid asyncMethod(Object args, Callback callback) { ... } }
Callback.Adapter
Constructor and Description |
---|
BlockingCallback() |
Modifier and Type | Method and Description |
---|---|
void |
block()
Block until the FutureCallback is done or cancelled and
after the return leave in the state as if a
#reset() had been
done. |
void |
failed(Throwable cause)
Callback invoked when the operation fails.
|
void |
succeeded()
Callback invoked when the operation completes.
|
String |
toString() |
public void succeeded()
Callback
Callback invoked when the operation completes.
succeeded
in interface Callback
Callback.failed(Throwable)
public void failed(Throwable cause)
Callback
Callback invoked when the operation fails.
public void block() throws IOException
#reset()
had been
done.
This is useful for code that wants to repeatable use a FutureCallback to convert
an asynchronous API to a blocking API.IOException
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.