Code Monkey home page Code Monkey logo

Comments (11)

olafleur avatar olafleur commented on August 22, 2024

I don't understand your question.

On one side we declare an interface that will be called to make a REST call (for example in a presenter). On the other hand, it is the server side, which will receive it and return the response and content, depending on the case.

Could you clarify a little bit more what implementation you are expecting?

from gwtp-samples.

olafleur avatar olafleur commented on August 22, 2024

"In the carstore sample project, the only resource that uses RestAction"
It's probably because we didn't change the other services to this more idiomatic way of doing things. ;)

The general principle is that Rest-Distpach (client-side) uses an interface. As we also do our backends in Java, we put that interface (for example StatisticsResource) in a shared package.
That way, we can implement that interface on the server-side (StatisticsResourceImpl).

But Rest-Dispatch is a client-side library, so your backend could be in any language that you want.

from gwtp-samples.

rtribotte avatar rtribotte commented on August 22, 2024

Yes absolutly, i will detail to be clear enougth.

I followed the documentation to use your Rest-Dispatch module. If i read well, in this documentation you cover the project configurations, the dependencies, the definition of the service (interface), and the usage in the presenter, but nothing on the way to implement the service on the server side.

So, i have no problems with the interface that define what the service provides, on the client side, which could be:

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

    @GET
    RestAction<FooDTO> getFoo();

}

nor with the usage of RestDispatch in a presenter:

@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) {

    }
});

But, on the server side, how do i implements the service and return RestAction ?

So I reviewed your project to determine how you implemented the services.

As far as i can tell, in the carstore project, the RestAction interface is used only one time in the https://github.com/ArcBees/GWTP-Samples/blob/master/carstore/src/main/java/com/gwtplatform/carstore/shared/api/StatisticsResource.java interface.

But the interface isn't used, even in a module e.g.:

bind(FooResource.class).to(FooResourceImpl.class);

In place of something like that i've found a simili-implementation (the interface isn't implemented) (https://github.com/ArcBees/GWTP-Samples/blob/master/carstore/src/main/java/com/gwtplatform/carstore/server/api/StatisticsResourceImpl.java) and this binding:

public class ApiModule extends AbstractModule {
    @Override
    protected void configure() {
        ...
        bind(StatisticsResourceImpl.class);
        ...
    }
}

Moreover in the presenter that uses this StatisticsResource, you are using the ResourceDelegate extension.

So my question is in fact how do i implement a service that is providing RestAction on the server side ? (without using Response and DelegateResource extension)

Thanks

from gwtp-samples.

rtribotte avatar rtribotte commented on August 22, 2024

Thanks for your second comment, i think that my previous comment will explain better what is my problem.

But when you say: "It's probably because we didn't change the other services to this more idiomatic way of doing things"
I assume it's not, since you are using ResourceDelegate in every presenters, and also because the RestDispatch is expecting RestAction:

public interface RestDispatch {
    <A extends RestAction<R>, R> DispatchRequest execute(A var1, AsyncCallback<R> var2);
}

from gwtp-samples.

olafleur avatar olafleur commented on August 22, 2024

One important thing that @Chris-V just reminded me is that there is a lot of magic that is generated by the Rest-Dispatch library.

from gwtp-samples.

rtribotte avatar rtribotte commented on August 22, 2024

I'm not sure to understand ^^
Sure there is a lot of magic behind the rest-library, but my only consideration is to implement the resource interface, in order to bind the interface to its implementation on the server side:

bind(FooResource.class).to(FooResourceImpl.class);

Long story short: how can i return a RestAction object

Clue (i don't know): i've seen in previous releases a RestService interface in rest-dispatch shared package, which seems to make the bind possible between a RestAction and a FooDTO, but it's no longer available in the current release

from gwtp-samples.

meriouma avatar meriouma commented on August 22, 2024

To achieve that, you need to use the dispatch-rest-delegates extension : https://github.com/ArcBees/gwtp-extensions/tree/master/dispatch-rest-delegates.
This will allow you to reuse your interfaces on the server-side. You can take a look at the CarStore for some examples : https://github.com/ArcBees/GWTP-Samples/tree/master/carstore

from gwtp-samples.

rtribotte avatar rtribotte commented on August 22, 2024

Indeed, i already make it work with the ResourceDelegate module, but like you announce it in the presentation of the extension, the type safety is not ensured by the language level.

I could go for ResourceDelegate, but it would be nicer for me to use the original strategy (i already said that i'm not willing to use ResourceDelegate).

Please re-read my comments, i think it's clear enough. Maybe, i'm looking for something which didn't exist already.

Thanks in advance

from gwtp-samples.

meriouma avatar meriouma commented on August 22, 2024

dispatch-rest is a client only library, that's why there's no information on how to implement it on the server-side. At the moment, the dispatch-rest-delegates is the only way you can use the same interfaces on both the client and the server. In fact the motivation behind the dispatch-rest-delegates was to do exactly what you want to do.

from gwtp-samples.

rtribotte avatar rtribotte commented on August 22, 2024

I understand that rest-dispach is a client only library (i was blind).
There was previously two package, client and shared for rest-dispatch. So there was a part that could be used by the server.
This is why i was confused, i probably digged to much, looking for something more like rpc.

Thanks for your time.

ps: i still believe that ResourceDelegate is a partial solution, are you working on something else ?
Great work though

from gwtp-samples.

christiangoudreau avatar christiangoudreau commented on August 22, 2024

What are your thoughts? There's a couple of road that could be taken, but few leads to where we wanted to go. If you have anything on your mind that could help us think about another direction that we might have not think about, you're more than welcome :D

from gwtp-samples.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.