private void delegateExecute(ClientActionHandler<A, R> clientActionHandler) { dispatchRequest.setDelegate(clientActionHandler.execute(action, callback, this)); } }
@SuppressWarnings("unchecked") @Override public <A extends Action<R>, R extends Result> DispatchRequest execute( A action, AsyncCallback<R> callback) { assert callback != null; ClientActionHandler<?, ?> clientActionHandler = clientActionHandlers.get(action.getClass()); if (clientActionHandler != null) { DelegatingDispatchRequest request = new DelegatingDispatchRequest(); ((ClientActionHandler<A, R>) clientActionHandler).execute(action, callback, new ExecuteCommand<A, R>() { @Override public DispatchRequest execute(A action, AsyncCallback<R> resultCallback) { return serviceExecute(action, resultCallback); } }); return request; } else { serviceExecute(action, callback); return new TestingDispatchRequest(); } }
@Override public void onSuccess(ClientActionHandler<?, ?> clientActionHandler) { if (clientActionHandler.getActionType() != action.getClass()) { dispatchRequest.cancel(); callback.onFailure(new ClientActionHandlerMismatchException( (Class<? extends Action<?>>) action.getClass(), clientActionHandler.getActionType())); return; } if (dispatchRequest.isPending()) { dispatchRequest.setDelegate(((ClientActionHandler<A, R>) clientActionHandler).execute( action, callback, new ExecuteCommand<A, R>() { @Override public DispatchRequest execute(A action, AsyncCallback<R> resultCallback) { if (dispatchRequest.isPending()) { return doExecute(securityCookie, action, resultCallback); } else { return null; } } })); } }