com.gwtplatform.dispatch.server.Dispatch Maven / Gradle / Ivy
/**
* Copyright 2011 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.gwtplatform.dispatch.server;
import com.gwtplatform.dispatch.shared.Action;
import com.gwtplatform.dispatch.shared.ActionException;
import com.gwtplatform.dispatch.shared.Result;
import com.gwtplatform.dispatch.shared.ServiceException;
/**
* The base class of the synchronous dispatcher service with an arbitrary action
* type. The server-side implementation is
* {@link com.gwtplatform.dispatch.server.guice.DispatchImpl} and the async
* client-side version is {@link DispatchAsync}.
*
* This class is closely related to
* {@link com.gwtplatform.dispatch.shared.DispatchService}. In fact, this class
* wouldn't be needed, but we use it to workaround a GWT limitation described in
* {@link com.gwtplatform.dispatch.shared.DispatchAsync}.
*
* @author Christian Goudreau
* @author David Peterson
*/
public interface Dispatch {
/**
* Executes the specified action and returns the appropriate result.
*
* @param The {@link Action} type.
* @param The {@link Result} type.
* @param action The {@link Action}.
* @return The action's result.
* @throws ActionException if the action execution failed.
* @throws ServiceException if the execution failed due to a service error.
*/
, R extends Result> R execute(A action)
throws ActionException, ServiceException;
/**
* Undoes a previously executed action.
*
* @param The {@link Action} type.
* @param The {@link Result} type.
* @param action The {@link Action} to undo.
* @param result The result obtained when the action was previously executed.
* @throws ActionException if undoing the action failed.
* @throws ServiceException if the execution failed due to a service error.
*/
, R extends Result> void undo(A action, R result)
throws ActionException, ServiceException;
}