I watched "Google Web Toolkit Architecture: Best Practices for Architecting Your GWT App" and I'm having trouble figuring out how the server side is supposed to work.
Slide 21 shows:
/** The name Command is taken */
interface Action<T extends Response> { }
interface Response { }
interface ContactsService extends RemoteService {
<T extends Response> T execute(Action<T> action);
}
interface ContactsServiceAsync {
<T extends Response> void execute(Action<T> action,
AsyncCallback<T> callback);
}
I thought that meant I might be able to create
public ResponseSubclass execute(ActionSubclass action) { ... }
and gwt would choose that method when it matches my exact parameters, but it doesn't. At the moment i'm using:
if (action.getClass().getName() == ActionSubclass.class.getName())
{
return (T) execute((ActionSubclass)action);
}
but that means I have to keep adding ifs to that method every time I add an action and I have to use unchecked casts. Is there a better way to make this work?
note: from what I have read somewhere else, the command pattern would usually include the actions to be taken in the Ac subclass, but because this is passing a client object for the server take some action on, the execution of the action has to be separated.