Package com.google.gerrit.httpd.rpc
Class Handler<T>
- java.lang.Object
-
- com.google.gerrit.httpd.rpc.Handler<T>
-
- Type Parameters:
T
- type of result forAsyncCallback.onSuccess(Object)
if the operation completed successfully.
- All Implemented Interfaces:
Callable<T>
- Direct Known Subclasses:
ProjectAccessHandler
public abstract class Handler<T> extends Object implements Callable<T>
Base class for RPC service implementations.Typically an RPC service implementation will extend this class and use Guice injection to manage its state. For example:
class Foo extends Handler<Result> { interface Factory { Foo create(... args ...); } @Inject Foo(state, @Assisted args) { ... } Result get() throws Exception { ... } }
-
-
Constructor Summary
Constructors Constructor Description Handler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
call()
Compute the operation result.void
to(com.google.gwtjsonrpc.common.AsyncCallback<T> callback)
Run the operation and pass the result to the callback.static <T> Handler<T>
wrap(Callable<T> r)
-
-
-
Method Detail
-
to
public final void to(com.google.gwtjsonrpc.common.AsyncCallback<T> callback)
Run the operation and pass the result to the callback.- Parameters:
callback
- callback to receive the result ofcall()
.
-
call
public abstract T call() throws Exception
Compute the operation result.- Specified by:
call
in interfaceCallable<T>
- Returns:
- the result of the operation. Return
VoidResult.INSTANCE
if there is no meaningful return value for the operation. - Throws:
Exception
- the operation failed. The caller will log the exception and the stack trace, if it is worth logging on the server side.
-
-