1 / 13

JAX-RS – REST in Java

JAX-RS – REST in Java. Agenda. Introduction Compare to SOAP Server code Client code Frameworks. Introduction. Representational state transfer (Roy Fieding) Every URL represents an object or a state Who uses it? Amazon AWS (EC2, S3, etc.) Flickr Del.ici.ous Ebay CRUD by HTTP methods

nadda
Download Presentation

JAX-RS – REST in Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JAX-RS – REST in Java

  2. Agenda Introduction Compare to SOAP Server code Client code Frameworks

  3. Introduction Representational state transfer (Roy Fieding) Every URL represents an object or a state Who uses it? Amazon AWS (EC2, S3, etc.) Flickr Del.ici.ous Ebay CRUD by HTTP methods Create → POST Read → GET Update → PUT Delete → DELETE

  4. Compare to SOAP REST advantages Lightweight - not a lot of extra xml markup Human Readable Results Easy to build - no toolkits required SOAP advantages Easy to consume – sometimes Rigid - type checking, adheres to a contract Development tools

  5. Server code Servlet API web.xml mapping doGet, doPost, doUpdate, doDelete Payload marshalling/unmarshalling Example JSR-311 (JAX-RS) Example

  6. JAX-RS features Annotation based Deployment JAX-RS aware container javax.ws.rs.Application Servlet container Servlet Filter J2SE RuntimeDelegate.createEndpoint HTTP Data handling @Provider

  7. JAX-RS HTTP Templated mapping and subresources @Path MIME handling @Provides, @Consumes HTTP methods @GET, @POST, @UPDATE, @DELETE, @HEAD, @OPTIONS, @HttpMethod Caching evaluatePreconditions

  8. JAX RS data handling URI templates {name} {regex} Parameters @PathParam @QueryParam @FormParam @MatrixParam @HeaderParam @SessionParam @UriInfo @Encoded @CoockieParam @DefaultValue No annotation (entity) Return values Resporse GenericEntity Null Status 204 Entity (marshalled) Exceptions WebApplicationException Unchecked Filters, error pages Checked ServletException, WebServiceException @Provider extends ExceptionMapper

  9. Entities Primitives String enum byte [], File, DataSource, etc. JAXB valueOf List, Set, SortedSet – not worked for me :-( @Provider MessageBodyReader MessageBodyWriter

  10. Client code Old school – javascript, HttpClient REST oriented APIs No standard spec Framework offer good APIs org.jboss.resteasy.client.core com.sun.jersey.api.client

  11. Frameworks Jboss resteasy Sun jersey CXF Axis2 Spring Others?

  12. Q & A

  13. Thank you

More Related