Using Generics with GWT-RPC does not work as expected

Instead of creating hundreds of different classes of GWT-RPC and Async services, I am trying to create a single service using generics. Here's the interface:

@RemoteServiceRelativePath("dispatch")
public interface CommandService extends RemoteService
{
    public <T> Result<T> execute(Command command, T target);
}

Here Commandis an enumeration of all the various commands that I can issue, for example Login, Register, ChangePassword', etc. On the server side, I have HashMapof Commandas the key, and a Executoras the value. For each Command, I have a corresponding one Executor. Running Executor, and its return value is returned on the server side.

The problem occurs when I try to create CommandServiceAsyncon the client and try to execute it. Here is my code for this:

public enum Command
{
    LOGIN,
    REGISTER,
    CHANGE_PW;

    public <T> void execute(T target, final ResultReceiver<T> receiver)
    {
        CommandServiceAsync command = GWT.create(CommandService.class );
        command.execute(this, target, new AsyncCallback<Result<T> >()
        {
            @Override
            public void onFailure(Throwable caught)
            {
                MyProgram.handleFailure(caught);
            }

            @Override
            public void onSuccess(Result<T> result)
            {
                receiver.receive( result );;
            }
        });
    }
}

Command.execute - , . LOGIN:

LoginForm form = new LoginForm();
Command.LOGIN.execute(form, new ResultReceiver<LoginForm>()
{
    @Override
    public void receive(Result<LoginForm> result)
    {
        Console.debug("Received result");
        //result.getTarget() will return an instance of LoginForm
        Console.debug("user: " + result.getTarget().getUser() );
        Console.debug("pw: " + result.getTarget().getUser() );
    }
});

Command.execute:

CommandServiceAsync command = GWT.create(CommandService.class );

:

: 'com.xxx.CommandService';

: com.google.gwt.event.shared.UmbrellaException: : "com.xxx.CommandService" ( ?)

: com.google.gwt.core.ext.UnableToCompleteException: (. )

, ?

+3
2

GWT . , , , .

-

public interface CommandService extends RemoteService {
    public Result<Serializable> execute(Command command, Serializable target);
}

, .

Factory . , .

GWT Factory. - gwtproject.org . README eclipse. .

Edit:

@ColinAlworth, RPC-. , Serializable , , !

+5

GWT-RPC - . , , . , GWT . , . . .

RPC

+1

All Articles