void abort(final Throwable t) { if (future != null) { future.abort(t); } }
@Override public void cancelled() { future.cancel(true); }
@SuppressWarnings(value = {"unchecked"}) void done(Object result) { if (future != null) { future.done(result); } }
@Override public void completed(V result) { runListeners(); }
responseFuture.setAsyncHandler(newHandler); responseFuture.setHttpTransactionCtx(newContext);
public void abort(Throwable t) { if (done.get() || !cancelled.compareAndSet(false, true)) { return; } delegate.failure(t); if (handler != null) { try { handler.onThrowable(t); } catch (Throwable ignore) { } } closeConnection(); runListeners(); }
new GrizzlyResponseFuture<T>(asyncHandler);
final GrizzlyResponseFuture<T> future = new GrizzlyResponseFuture<T>(this, request, handler, proxy); future.setDelegate(SafeFutureImpl.<T>create()); final CompletionHandler<Connection> connectHandler = new CompletionHandler<Connection>() { @Override
public AsyncHandler getAsyncHandler() { return future.getAsyncHandler(); }
@Override public void completed(final Connection c) { try { final HttpTransactionContext tx = HttpTransactionContext.startTransaction(c, GrizzlyAsyncHttpProvider.this, request, future); if (future.setHttpTransactionCtx(tx)) { execute(tx); } else { // GrizzlyResponseFuture has been already completed (canceled?) tx.closeConnection(); } } catch (Exception e) { if (e instanceof RuntimeException) { failed(e); } else if (e instanceof IOException) { failed(e); } if (LOGGER.isWarnEnabled()) { LOGGER.warn(e.toString(), e); } } }
@Override public void cancelled() { final AsyncHandler ah = asyncHandler; if (ah != null) { try { ah.onThrowable(new CancellationException()); } catch (Throwable ignore) { } } runListeners(); }
responseFuture.setAsyncHandler(newHandler); responseFuture.setHttpTransactionCtx(newContext);
new GrizzlyResponseFuture<T>(asyncHandler);
public AsyncHandler getAsyncHandler() { return future != null ? future.getAsyncHandler() : null; }
@Override public void completed(final Connection c) { try { final HttpTransactionContext tx = HttpTransactionContext.startTransaction(c, GrizzlyAsyncHttpProvider.this, request, future); if (future.setHttpTransactionCtx(tx)) { execute(tx); } else { // GrizzlyResponseFuture has been already completed (canceled?) tx.closeConnection(); } } catch (Exception e) { if (e instanceof RuntimeException) { failed(e); } else if (e instanceof IOException) { failed(e); } if (LOGGER.isWarnEnabled()) { LOGGER.warn(e.toString(), e); } } }
@Override public void failed(final Throwable throwable) { future.abort(throwable); }
@Override public void failed(final Throwable t) { final AsyncHandler ah = asyncHandler; if (ah != null) { try { ah.onThrowable(t); } catch (Throwable ignore) { } } final HttpTransactionContext tx = transactionCtx; if (tx != null) { tx.closeConnection(); } runListeners(); }
public void cancelled() { future.cancel(true); }