@SuppressWarnings("unchecked") protected void delegateExecute(RpcInterceptor<A, R> interceptor) { dispatchRequest.setDelegate(interceptor.execute(action, callback, this)); }
@Override public void onFailure(Throwable caught) { dispatchRequest.cancel(); callback.onFailure(caught); } });
@Override public DispatchRequest execute(A action, AsyncCallback<R> resultCallback) { if (dispatchRequest.isPending()) { return dispatchCall.processCall(); } else { return null; } }
@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; } } })); } }
@SuppressWarnings("unchecked") @Override public <A extends Action<R>, R extends Result> DispatchRequest undo(A action, R result, AsyncCallback<Void> callback) { ClientActionHandler<?, ?> clientActionHandler = clientActionHandlers.get(action.getClass()); if (clientActionHandler != null) { DelegatingDispatchRequest request = new DelegatingDispatchRequest(); ((ClientActionHandler<A, R>) clientActionHandler).undo(action, result, callback, new UndoCommand<A, R>() { @Override public DispatchRequest undo(A action, R result, AsyncCallback<Void> callback) { return serviceUndo(action, result, callback); } }); return request; } else { serviceUndo(action, result, 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).undo( action, result, callback, new UndoCommand<A, R>() { @Override public DispatchRequest undo(A action, R result, AsyncCallback<Void> callback) { if (dispatchRequest.isPending()) { return doUndo(securityCookie, action, result, callback); } else { return null; } } })); } }
@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(); } }
@SuppressWarnings({"unchecked"}) protected <R> void execute(RestAction<R> action) { DispatchRequest dispatchRequest = dispatcher.execute(action, (AsyncCallback<R>) callback); if (delegatingDispatchRequest != null) { delegatingDispatchRequest.setDelegate(dispatchRequest); } }
@Override public void onFailure(Throwable caught) { dispatchRequest.cancel(); dispatchCall.onExecuteFailure(caught); }
@SuppressWarnings("unchecked") @Override public void onSuccess(ClientActionHandler<?, ?> clientActionHandler) { if (clientActionHandler.getActionType() != action.getClass()) { delegateFailure(clientActionHandler); } else if (dispatchRequest.isPending()) { delegateExecute((ClientActionHandler<A, R>) clientActionHandler); } }
final DelegatingDispatchRequest dispatchRequest = new DelegatingDispatchRequest(); clientActionHandlerProvider.get(new AsyncCallback<ClientActionHandler<?, ?>>() { @Override
private void updateDispatchRequest() { if (dispatchRequest != null) { delegateMocking.getDelegatingDispatchRequest().setDelegate(dispatchRequest); } } }
@Override public void onFailure(Throwable caught) { dispatchRequest.cancel(); callback.onFailure(caught); } });
@Override public DispatchRequest execute(A action, AsyncCallback<R> resultCallback) { if (dispatchRequest.isPending()) { RpcDispatchExecuteCall<A, R> newDispatchCall = dispatchCallFactory.create(action, resultCallback); newDispatchCall.setIntercepted(true); return newDispatchCall.execute(); } else { return null; } }
final DelegatingDispatchRequest dispatchRequest = new DelegatingDispatchRequest(); clientActionHandlerProvider.get(new AsyncCallback<ClientActionHandler<?, ?>>() { @Override
private void delegateExecute(ClientActionHandler<A, R> clientActionHandler) { dispatchRequest.setDelegate(clientActionHandler.execute(action, callback, this)); } }
@Override public void onFailure(Throwable caught) { dispatchRequest.cancel(); dispatchCall.onExecuteFailure(caught); }
protected void handleSuccess(RpcInterceptor<?, ?> interceptor) { if (!interceptor.canExecute(action)) { delegateFailure(interceptor); } else if (getDispatchRequest().isPending()) { delegateExecute((RpcInterceptor<A, R>) interceptor); } }
@Override public DispatchRequest execute() { A action = getAction(); dispatchHooks.onExecute(action, false); if (!isIntercepted()) { IndirectProvider<RpcInterceptor<?, ?>> interceptorIndirectProvider = interceptorRegistry.find(action); if (interceptorIndirectProvider != null) { DelegatingDispatchRequest dispatchRequest = new DelegatingDispatchRequest(); RpcInterceptedAsyncCallback<A, R> delegatingCallback = new RpcInterceptedAsyncCallback<>( dispatchCallFactory, this, action, getCallback(), dispatchRequest); interceptorIndirectProvider.get(delegatingCallback); return dispatchRequest; } } return processCall(); }
@SuppressWarnings("unchecked") protected void delegateExecute(Interceptor interceptor) { dispatchRequest.setDelegate(interceptor.execute(action, callback, this)); }