|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.jersey.api.client.async.TypeListener<T>
T - the type of the response.public abstract class TypeListener<T>
A listener to be implemented by clients that wish to receive callback notification of the completion of requests invoked asynchronously.
This listener is a helper class providing implementions for the methods
ITypeListener.getType() and ITypeListener.getGenericType().
Instances of this class may be passed to appropriate methods on
AsyncWebResource (or more specifically methods on
AsyncUniformInterface). For example,
AsyncWebResource r = ..
Future<String> f = r.get(new TypeListener<String>(String.class) {
public void onComplete(Future<String> f) throws InterruptedException {
try {
String s = f.get();
} catch (ExecutionException ex) {
// Do error processing
if (t instanceof UniformInterfaceException) {
// Request/response error
} else
// Error making request e.g. timeout
}
}
}
});
| Constructor Summary | |
|---|---|
TypeListener(java.lang.Class<T> type)
Construct a new listener defining the class of the response to receive. |
|
TypeListener(GenericType<T> genericType)
Construct a new listener defining the generic type of the response to receive. |
|
| Method Summary | |
|---|---|
GenericType<T> |
getGenericType()
Get the generic type declaring the Java type of the instance to receive for FutureListener.onComplete(java.util.concurrent.Future). |
java.lang.Class<T> |
getType()
Get the class of the instance to receive for FutureListener.onComplete(java.util.concurrent.Future). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sun.jersey.api.client.async.FutureListener |
|---|
onComplete |
| Constructor Detail |
|---|
public TypeListener(java.lang.Class<T> type)
type - the class of the response.public TypeListener(GenericType<T> genericType)
genericType - the generic type of the response.| Method Detail |
|---|
public java.lang.Class<T> getType()
ITypeListenerFutureListener.onComplete(java.util.concurrent.Future).
getType in interface ITypeListener<T>public GenericType<T> getGenericType()
ITypeListenerFutureListener.onComplete(java.util.concurrent.Future).
getGenericType in interface ITypeListener<T>ITypeListener.getType() must not return null. Otherwise, if not null,
the type information declared by the generic type takes
precedence over the value returned by ITypeListener.getType().
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||