use of org.glassfish.jersey.examples.rx.domain.AgentResponse in project jersey by jersey.
the class ListenableFutureAgentResource method listenable.
@GET
@ManagedAsync
public void listenable(@Suspended final AsyncResponse async) {
final long time = System.nanoTime();
final AgentResponse response = new AgentResponse();
// Obtain and set visited and recommended places to create a response ...
final ListenableFuture<List<AgentResponse>> successful = Futures.successfulAsList(Arrays.asList(visited(response), recommended(response)));
// ... and when we have them, return response to the client.
Futures.addCallback(successful, new FutureCallback<List<AgentResponse>>() {
@Override
public void onSuccess(final List<AgentResponse> result) {
response.setProcessingTime((System.nanoTime() - time) / 1000000);
async.resume(response);
}
@Override
public void onFailure(final Throwable t) {
async.resume(t);
}
});
}
Aggregations