use of org.qi4j.library.rest.client.spi.ResponseHandler in project qi4j-sdk by Qi4j.
the class ContextResourceClient method onCommand.
public <T> ContextResourceClient onCommand(String relation, final ResultHandler<T> handler) {
final Class<T> resultType = (Class<T>) Classes.RAW_CLASS.map(((ParameterizedType) handler.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0]);
commandHandlers.put(relation, new ResponseHandler() {
@Override
public HandlerCommand handleResponse(Response response, ContextResourceClient client) {
T result = contextResourceFactory.readResponse(response, resultType);
return handler.handleResult(result, client);
}
});
return this;
}
use of org.qi4j.library.rest.client.spi.ResponseHandler in project qi4j-sdk by Qi4j.
the class HandlerCommand method onProcessingError.
public <T> HandlerCommand onProcessingError(final ResultHandler<T> resultHandler) {
final Class<T> resultType = (Class<T>) Classes.RAW_CLASS.map(((ParameterizedType) resultHandler.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0]);
this.processingErrorHandler = new ResponseHandler() {
@Override
public HandlerCommand handleResponse(Response response, ContextResourceClient client) {
T result = client.getContextResourceClientFactory().readResponse(response, resultType);
return resultHandler.handleResult(result, client);
}
};
return this;
}
Aggregations