// Asynchronous mode where a callback
// object is to be called.
isSynchronous = false;
// Get the kind of result expected.
final Result rCallback = (Result) o;
Type[] genericParameterTypes = javaMethod
.getGenericParameterTypes();
Type genericParameterType = genericParameterTypes[i];
ParameterizedType parameterizedType = (genericParameterType instanceof java.lang.reflect.ParameterizedType) ? (java.lang.reflect.ParameterizedType) genericParameterType
: null;
final Class<?> actualType = (parameterizedType
.getActualTypeArguments()[0] instanceof Class<?>) ? (Class<?>) parameterizedType
.getActualTypeArguments()[0] : null;
// Define the callback
Uniform callback = new Uniform() {
@SuppressWarnings("unchecked")
public void handle(Request request,
Response response) {
if (response.getStatus().isError()) {
rCallback
.onFailure(new ResourceException(
response.getStatus()));
} else {
if (actualType != null) {
rCallback
.onSuccess(getClientResource()
.toObject(
response.getEntity(),
actualType
.getClass()));
} else {
rCallback.onSuccess(null);
}
}
}
};