The idea of this talk is to explain the architectural design concepts behind REST APIS and its roles in modern web APIs.This is a presentation at Barcamp Saigon 2012.
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
REST Architectural Style: A Detail Explain
1. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
REST Architectural Style: A Detail Explain
Cao Duc Nguyen
nguyen.cao-duc@hp.com
Software Designer
April 26, 2012
2. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Outline
1
Introduction
Web APIs
2
REST Fundamentals
HTTP
REST
3
Java Open Source RESTful Web Services
Specification
Implementation
4
Conclusion
Discussion
Final word
Conclusion
14. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
HTTP
HTTP Methods in more details
GET
Safe, Idempotent, Cacheable
PUT
Idempotent
DELETE
Idempotent
HEAD
Safe, Idempotent
OPTIONS
Safe, Idempotent
POST
Safe The client did not request any side-effects on
server other than data retrieval.
Idempotent Any side-effects on the server of several identical
idempotent methods are the same as the
side-effects of one single method.
Cacheable Explain in more details later. . .
15. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
HTTP
Intermediaries - Cache
A new request for a cached resource can be returned
immediately by intermediary caches.
Conclusion
16. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
HTTP
Intermediaries - Proxy & Gateway
Proxy
an intermediary selected by a client, to provide
interfaces to services like data translation,
performance enhancement, or security protection.
Gateway
an intermediary imposed by the network or origin
server to provide an interface encapsulation of
other services, for data translation, performance
enhancement, or security enforcement.
17. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
HTTP
Stateless
HTTP Requests are stateless, which means each request is
independent from the others.
18. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
HTTP
Stateless
HTTP Requests are stateless, which means each request is
independent from the others.
intermediaries only need to work on a single interaction
without knowing the entire topology
19. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
REST
REST Architectural Style
REpresentational State Transfer
The representation returned by the server places
or transfers the client from state to state.
REST Architectural Style
. . . a set of architectural constraints that, when
applied as a whole, emphasizes scalability of
component interactions, generality of interfaces,
independent deployment of components,
intermediary components to reduce interaction
latency, enforce security, and encapsulate legacy
systems.
Roy T. Fielding
24. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
Specification
JAX-RS Hello Example
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@Path("/hello/{username}")
public class Hello {
private String name="no-one";
@GET
@Produces("text/plain")
public String hello(@PathParam("username")
String userName) {
userName = userName==null?name:userName;
return " Hello, "+userName;
}
25. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
Specification
JAX-RS Hello Example
@POST
@Consumes("text/plain")
public String hello(@FormParam("username")
String userName) {
name = userName==null?name:userName;
return " Hello, "+userName;
}
}
26. Introduction
REST Fundamentals
Java Open Source RESTful Web Services
Conclusion
Implementation
Open Sources RESTful Web Service Implementation of JAX-RS
Jersey - Sun reference implementation
RESTEasy - JBoss
Restlet