The document provides an overview of REST (Representational State Transfer) and the Java API for RESTful Web Services (JAX-RS). It discusses REST constraints like using URIs, HTTP methods, and media types. It then demonstrates how to build a RESTful web service in Java using JAX-RS annotations for paths, parameters, responses, and caching.
Pragmatic explanation UseHTTP the way it was designed to be used Take advantage of the good things in HTTP By following a set of constraints
5.
Constraints in RESTGive everything its own URI Communicate with a standard set of methods Communicate with Media Types Link your resources together Avoid session state Support caching * This is a very simplified version of the real REST constraints, for the real stuff read Roy Fieldings dissertation
For the interestedRoy Fieldings PhD dissertation, see ch 5 http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm Roy Fieldings blog http://roy.gbiv.com/untangled/ Mark Hadleys blog http://weblogs.java.net/blog/mhadley/ Mark Nottinghams blog http://www.mnot.net Stefan Tilkovs blog http://www.innoq.com/blog/st/
Serendipity By givingeverything a URL, sticking to a Uniform Interface and linking your resources you make the chances of reuse in unexpected ways higher
29.
Statelessness Better scalingNo session storage on server Any server in a cluster can handle any request The resources can safely be cached More reliable A client can safely re-send a request Better resource reuse The resources can safely be linked to
“ The bestrequests are those that not even reach me.” - Anonymous overloaded Server
33.
50 requests/second =3000 requests/minute setting max-age=60 (seconds) can then save you 2999 requests
34.
Caching GET canbe cached while POST can't (safely) Specify max-age Use max-age cache control header Split data according to freshness requirement Support conditional GET Get if modified since E-tags