@Override protected <A extends Action<R>, R extends Result> DispatchRequest doUndo( String securityCookie, final A action, final R result, final AsyncCallback<Void> callback) { return new GwtHttpDispatchRequest(realService.undo(securityCookie, action, result, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { RpcDispatchAsync.this.onUndoFailure(action, caught, callback); } public void onSuccess(Void voidResult) { RpcDispatchAsync.this.onUndoSuccess(action, voidResult, callback); } })); }
@Override protected <A extends Action<R>, R extends Result> DispatchRequest doExecute( String securityCookie, final A action, final AsyncCallback<R> callback) { return new GwtHttpDispatchRequest(realService.execute(securityCookie, action, new AsyncCallback<Result>() { public void onFailure(Throwable caught) { RpcDispatchAsync.this.onExecuteFailure(action, caught, callback); } @SuppressWarnings("unchecked") public void onSuccess(Result result) { // Note: This cast is a dodgy hack to get around a GWT // 1.6 async compiler issue RpcDispatchAsync.this.onExecuteSuccess(action, (R) result, callback); } })); }
@Override protected DispatchRequest processCall() { return new GwtHttpDispatchRequest(dispatchService.undo(getSecurityCookie(), getAction(), result, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { RpcDispatchUndoCall.this.onExecuteFailure(caught, null); dispatchHooks.onFailure(getAction(), caught, true); } @Override public void onSuccess(Void nothing) { RpcDispatchUndoCall.this.onExecuteSuccess(result, null); dispatchHooks.onSuccess(getAction(), result, true); } } )); } }
@Override protected DispatchRequest processCall() { Request request = dispatchService.execute(getSecurityCookie(), getAction(), new AsyncCallback<R>() { @Override public void onFailure(Throwable caught) { RpcDispatchExecuteCall.this.onExecuteFailure(caught, null); dispatchHooks.onFailure(getAction(), caught, false); } @Override public void onSuccess(R result) { RpcDispatchExecuteCall.this.onExecuteSuccess(result, null); dispatchHooks.onSuccess(getAction(), result, false); } } ); return new GwtHttpDispatchRequest(request); } }
/** * Execution entry point. Call this method to execute the {@link RestAction action} wrapped by this instance. * * @return a {@link DispatchRequest} object. */ public DispatchRequest execute() { try { RequestBuilder requestBuilder = createRequest(); cookieManager.saveCookiesFromAction(action); return new GwtHttpDispatchRequest(requestBuilder.send()); } catch (RequestException | ActionException e) { callback.onFailure(e); } return new CompletedDispatchRequest(); }