/** * @see io.apiman.gateway.engine.io.IWriteStream#end() */ @Override public void end() { // Called when the upload to the 'API' is complete. This is when we // need to response with the connection response. handler.handle(AsyncResultImpl.<IApiConnectionResponse>create(this)); }
/** * Creates the handler to use when an error is detected during the processing * of a chain. */ private IAsyncHandler<Throwable> createPolicyErrorHandler() { return error -> resultHandler.handle(AsyncResultImpl.<IEngineResult> create(error)); } }
private <T> Handler<AsyncResult<T>> handleSuccessfulResult(IAsyncResultHandler<Void> failureHandler, Handler<T> successHandler) { return result -> { if (result.succeeded()) { successHandler.handle(result.result()); } else { failureHandler.handle(AsyncResultImpl.create(result.cause())); } }; }
/** * @see io.apiman.gateway.engine.components.jdbc.IJdbcConnection#setAutoCommit(boolean, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void setAutoCommit(boolean autoCommit, IAsyncResultHandler<Void> handler) { try { connection.setAutoCommit(autoCommit); handler.handle(AsyncResultImpl.create((Void) null, Void.class)); } catch (SQLException e) { handler.handle(AsyncResultImpl.create(e, Void.class)); } }
/** * @see io.apiman.gateway.engine.components.ISharedStateComponent#clearProperty(java.lang.String, java.lang.String, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public <T> void clearProperty(String namespace, String propertyName, IAsyncResultHandler<Void> handler) { QName key = new QName(namespace, propertyName); synchronized (sharedState) { sharedState.remove(key); } handler.handle(AsyncResultImpl.create((Void) null)); }
protected void checkLoadingStatus() { if (handler != null && !failed && finishedLoading && asyncInitializeAwaiting.get() == 0) { handler.handle(AsyncResultImpl.create((Void) null)); } }
@Override public void abort(Throwable t) { done = true; payloadResultHandler.handle(AsyncResultImpl.create(new RuntimeException("Inbound request stream aborted.", t))); //$NON-NLS-1$ }
private void checkSuccess(URILoadingRegistry reg) { if (!failed) { handlers.get(reg).handle(AsyncResultImpl.create((Void) null)); } } }
@SuppressWarnings("unchecked") private <T> Handler<AsyncResult<CompositeFuture>> handleCompositeResult(IAsyncResultHandler<T> apimanResultHandler) { return result -> { if (result.succeeded()) { apimanResultHandler.handle(AsyncResultImpl.create((T) result.result())); } else { apimanResultHandler.handle(AsyncResultImpl.create(result.cause())); } }; }
@SuppressWarnings("unchecked") private <T, Q> Handler<AsyncResult<Q>> handleResult(IAsyncResultHandler<T> apimanResultHandler) { return result -> { if (result.succeeded()) { apimanResultHandler.handle(AsyncResultImpl.create((T) result.result())); } else { apimanResultHandler.handle(AsyncResultImpl.create(result.cause())); } }; }
private Handler<AsyncResult<Void>> handleResultVoid(IAsyncResultHandler<Void> apimanResultHandler) { return result -> { if (result.succeeded()) { apimanResultHandler.handle(AsyncResultImpl.create(result.result())); } else { apimanResultHandler.handle(AsyncResultImpl.create(result.cause())); } }; } }
static <T, R> Handler<AsyncResult<T>> translateFailureHandler(IAsyncResultHandler<R> apimanResult) { return result -> { if (!result.succeeded()) { apimanResult.handle(AsyncResultImpl.create(result.cause())); } }; } }
@Override public void getClient(String organizationId, String clientId, String clientVersion, IAsyncResultHandler<Client> handler) { try { Client client = lookupClient(organizationId, clientId, clientVersion); handler.handle(AsyncResultImpl.create(client)); } catch (ClientNotFoundException e) { handler.handle(AsyncResultImpl.create(e, Client.class)); } }
/** * @see io.apiman.gateway.engine.IRegistry#getClient(java.lang.String, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void getClient(String apiKey, IAsyncResultHandler<Client> handler) { try { Client client = getClientInternal(apiKey); handler.handle(AsyncResultImpl.create(client)); } catch (SQLException e) { handler.handle(AsyncResultImpl.create(e, Client.class)); } }
/** * @see io.apiman.gateway.engine.jdbc.JdbcRegistry#getClient(java.lang.String, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void getClient(String apiKey, IAsyncResultHandler<Client> handler) { try { Client client = getClient(apiKey); handler.handle(AsyncResultImpl.create(client)); } catch (IOException e) { handler.handle(AsyncResultImpl.create(e, Client.class)); } }
@Override public void close(IAsyncResultHandler<Void> closeResultHandler) { close(); closeResultHandler.handle(AsyncResultImpl.create((Void) null)); }
@Override public void handle(IAsyncResult<Void> result) { if (result.isSuccess()) { updateDataVersion(); } handler.handle(result); } });
/** * @see io.apiman.gateway.engine.async.IAsyncHandler#handle(java.lang.Object) */ @Override public void handle(IAsyncResult<Void> result) { if (result.isSuccess()) { updateDataVersion(); } handler.handle(result); } });