|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface ResultListener<T>
Provides access to a future result, or the exception associated with failure. In the trying course of implementing a method, one is often left with no choice but to foist control off onto another thread or generally postpone things beyond the lifetime of the current call. In such circumstances, it is handy to have a general purpose mechanism for leting the caller know when things are done and whether or not the succeeded; this class serves that purpose.
The following contrived example will hopefully communicate its use more clearly than the previous paragraph of flowery prose:
public void doSomeStuff (ResultListenerlistener) { Runnable run = new Runnable () { public void run () { try { // do our thing listener.requestCompleted("Elvis!"); } catch (Exception e) { listener.requestFailed(e); } } }; new Thread(run).start(); }
IntResultListener| Nested Class Summary | |
|---|---|
static class |
ResultListener.NOOP<T>
A result listener that does nothing for cases where that is an appropriate behavior. |
| Field Summary | |
|---|---|
static ResultListener<Object> |
NOOP
Deprecated. This cannot be type safe so don't use it. |
| Method Summary | |
|---|---|
void |
requestCompleted(T result)
Called to communicate that the request succeeded and that the result is available. |
void |
requestFailed(Exception cause)
Called to communicate that the request failed and to provide the reason for failure. |
| Field Detail |
|---|
@Deprecated static final ResultListener<Object> NOOP
| Method Detail |
|---|
void requestCompleted(T result)
void requestFailed(Exception cause)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||