Search code examples
restgwtp

GWTP REST-Dispatch - What is the new usage for rest dispach, since the removal of the RestService interface in 1.5 release


Hi everybody,

I encounter implementation issues with the rest-dispatch module of the gwtp framework.

If i follow the current documentation, the resource interface defining what a service provide should be as follow:

@Path(FOO)
@Produces(MediaType.APPLICATION_JSON)
public interface FooResource {

    @GET
    RestAction<FooDTO> getFoo();

}

On the client side (without delegate extension):

@Inject RestDispatch dispatcher;
@Inject FooResource fooResource;

...
dispatcher.execute(fooResource.getFoo(), new AsyncCallback<FooDTO>() {
     @Override
     public void onFailure(Throwable throwable) {

     }

     @Override
     public void onSuccess(FooDTO fooDto) {

     }
});
...

Question

The RestDispatch is waiting for method that return RestAction, but since the RestService interface has been remove from 1.5 release:

How can i implements the FooResource ?

Moreover

In the carstore sample project, the only resource that uses RestAction is: https://github.com/ArcBees/GWTP-Samples/blob/master/carstore/src/main/java/com/gwtplatform/carstore/shared/api/StatisticsResource.java

But it's implementation, is in fact not an implementation in that case: https://github.com/ArcBees/GWTP-Samples/blob/master/carstore/src/main/java/com/gwtplatform/carstore/server/api/StatisticsResourceImpl.java

Should i follow this example, and what is the purpose of an non-implemented Interface ?

I assume that my question is very specific and it is maybe principally directed to the authors of gwtp.

And i thank in advance those who will respond.


Solution

  • The rest-dispatch is a client-library, and the interface that describes the services are not to use on the server side. I was attempting to do something not intended by the authors of GWTP.

    Yet, the DelegateResource extension is a solution, if you want to use the interface on the server side too. It comes with a drawback: the anability to have type safe callback on the client side.

    To go further, here the exchange i had with the team on github: https://github.com/ArcBees/GWTP-Samples/issues/92