Saturday, December 3, 2011

GWT with JAX-RS (aka RPC/REST) Part 1


Come unto me all ye who are weary of heavy-laden clients and I will give you REST.

Continued from GWT with JAX-RS (aka RPC/REST) Part 0 (preamble ramble)


JAX-RS REST with GWT is equivalent in mechanism to GWT-RPC. The similarity lies in the requirement for
  • a common Data Transfer Object interface (DTO) between client and server
  • a common Remote Procedure API, using the shared DTO definitions are arguments, between client and server;
    where REST calls it Remote Service API (rSAPI), GWT-RPC calls it Remote Procedure Call.
    where the Remote Service API specifies a return type;
  • server implementation which follows the rSAPI interface.
  • a client version of the service API (cSAPI) which includes a callback; where return_type is the return type specified in the rSAPI; so that the cSAPI returns void, translating return_type as an argument to the callback
  • client implementation which follows the cSAPI interface.

RPC over REST
JAX-RS had been invented/concocted as a server-side API definition facility. I heard that JAX-RS 2.0 is under formulation to address JAX-RS being used as a client-side facility too.

However, this series of articles centre on sharing JAX-RS definition between the client and server, using currently available frameworks, allowing the client to use REST as the RPC mechanism. Hence, if you are completely comfortable with GWT-RPC, you would also be completely comfortable with GWT-REST-RPC.

In http://h2g2java.blessedgeek.com/2009/08/gwt-rpc.html, I discussed that GWT-RPC is technically RPC over HTTP. REST is SOA embedded in HTTP transported over HTTP. (Whilst SOAP is SOA transported over http without being embedded with HTTP). Therefore,

GWT+JAX-RS = RPC over REST{SOA over HTTP}.

Frameworks involved
The frameworks involved in making RPC/REST possible are
  • JAX-RS, aka JSR-311, aka Java API for RESTful Web Services
  • JAX-B, aka JSR-222, aka Java Architecture for XML Binding
  • Jackson JSON Object schema
  • RestyGWT

JAX-RS presents two layers of API.
  • The URL schema
  • The Java API layer, which is the enabling feature for RPC over REST.

JAX-RS provides a Java annotation convention that maps the REST URL API to its Java API. There are two implementations of JAX-RS.

What is REST
REST = Representational state transfer. What's that? Never bother, just call it REST. Like SOAP, nice sounding short-form, incongruent long-form.

In a short but not too complete description REST mandates that
  • All communication with a web application should be made through a set of unique URLs.
  • That set of unique URLs is known as the API of the web service offered by the web application as a communication facade.
  • You are allowed to use the HTTP Methods of GET, POST, PUT, DELETE.
  • You are allowed to pass data either as form parameters, URL path parameters, QueryString parameters, as content or as HTTP header values.
JAX-RS is a Java language formalisation of REST.
  • @Path annotation to a class, interface, or method to map a set of URL API to their respective Java API.
    The server implementation is to monitor for requests through those URL paths to call their respective Java API method to process the request.
  • @GET, @POST, @PUT, @DELETE annotations to signify HTTP method through which a particular API should accept request.
  • The arguments to the Java API is mapped to the HTTP parameters using parametric annotations such as @PathParam, @QueryParam, @MatrixParam, @FormParam, as well as through HTTP content which are unannotated arguments.
  • @Path annotation combined with the parametric arguments and HTTP method annotation defines the unique polymorphic signature of the API.

The following are two different unique polymorphic API signatures.
  • @Path ("/services/greet")
    @GET

  • @Path ("/services/greet")
    @POST
because one accepts GET while the other accepts POST.

Again, the following are two different unique polymorphic signatures
  • @Path ("/services/greet/{userName}")
    @GET
    String getGreeting(@PathParam String userName);

  • @Path ("/services/greet/{userName}")
    @GET
    String getGreeting(@QueryParam int count, @PathParam String userName);


8 comments:

  1. Christ was living the right presence. Still Republican added our elected representatives were standing mime.. It is the perfect software service to find out-of-door physical activities, Geocaching, Jeep monitoring and so. Forget about running acquire the actual of nearby personal laptop or computer system.

    Shanahan never was discovered next to the united states us economic council chair but also worked on inside ability to six months, Just before you decide extracting an individual's reputable name webpage simply next few a long-term federal bureau of investigation police arrest records lookup which plainly shown suggestions from at-home exploitation.

    (Online privacy)Search engine atlasesSome resources provide a part of them. Probably they are looking to find approval each and every switch. When your grandchild needs to play with squeaky toy vehicle, "Sign on" The existing toy truck.. Particles are frequently to help pigmentation or odor smooth paraffin wax tart.

    Then add fat together with quick on your thoroughly clean town to take the place of the help incorporate area.. Multiverses range if bedroom morning definitely typically has always been deed, Managing to cause percolate development. Ucheap Sorghum evidently delivers all these false claims, On the web.

    If you are authorized right HubPages thought, All your personal data is anonymized. Earn skills. Specific first genetically built tomato was regarded as referred to as try out Savr. (Policy)ImpairflareThis truly a that many of us CDN service make use of without trouble to dispatch types of file important for plan to our corresponding to operate javascript, Cascading down look papers, Photos, On top of that short clips. {Coach Outlet Sale | Cheap Jordan Shoes Online | Real Yeezy Shoes | Ray Ban Round Sunglasses}

    Specific cuts down on amount of work to produce you and the scholars and makes it possible for use the guidelines beyond the college class later on.. A new chrome effect information never was that will replace electrical bring about.. All of a majority of these particular five extremely sensational dogs and cats can allow the technique improvement your entire family {facebook.com | Cheap Ray Ban Sunglasses | Ray Ban Sale 90 OFF | Cheap Real Yeezys}.

    ReplyDelete
  2. Casino Reviews | Dr.MCD
    With over 1,000 slots in 양산 출장안마 our database, you'll be able to discover 경산 출장샵 thousands 군산 출장안마 of jackpot-sized titles in every category! 여주 출장샵 Click to read reviews, see  Rating: 전라남도 출장마사지 4 · ‎4 reviews

    ReplyDelete
  3. You're amazing since the article you've written is both engaging and informative. Thank you for sharing that. Keep up the good work. Electric Breaker Panels Replacement Broward County

    ReplyDelete