Presentation is loading. Please wait.

Presentation is loading. Please wait.

JAX-RS – REST in Java.

Similar presentations

Presentation on theme: "JAX-RS – REST in Java."— 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 SOAP 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)

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

7 JAX-RS HTTP Templated mapping and subresources MIME handling
@Path MIME handling HTTP methods @HttpMethod Caching evaluatePreconditions

8 JAX RS data handling URI templates Parameters Return values Resporse
{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

Download ppt "JAX-RS – REST in Java."

Similar presentations

Ads by Google