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();
}
public void asyncMethod(Object args, Callback callback)
{
...
}
} Callback.Adapter| Constructor and Description |
|---|
BlockingCallback() |
| Modifier and Type | Method and Description |
|---|---|
void |
block()
Block until the Callback has succeeded or failed and
after the return leave in the state to allow reuse.
|
void |
failed(Throwable cause)
Callback invoked when the operation fails.
|
void |
succeeded()
Callback invoked when the operation completes.
|
String |
toString() |
public void succeeded()
CallbackCallback invoked when the operation completes.
succeeded in interface CallbackCallback.failed(Throwable)public void failed(Throwable cause)
CallbackCallback invoked when the operation fails.
public void block()
throws IOException
IOException - if exception was caught during blocking, or callback was cancelledCopyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.