rest architectural style: a detail explain

32
Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion REST Architectural Style: A Detail Explain Cao Duc Nguyen [email protected] Software Designer April 26, 2012

Upload: nguyen-cao

Post on 10-May-2015

463 views

Category:

Technology


1 download

DESCRIPTION

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.

TRANSCRIPT

Page 1: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST Architectural Style: A Detail Explain

Cao Duc [email protected]

Software Designer

April 26, 2012

Page 2: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Outline

1 IntroductionWeb APIs

2 REST FundamentalsHTTPREST

3 Java Open Source RESTful Web ServicesSpecificationImplementation

4 ConclusionDiscussionFinal word

Page 3: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

The Importance of APIs in Web Development

Page 4: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

APIs Timeline on ProgrammableWeb

Page 5: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

APIs Timeline on ProgrammableWeb in more details

Page 6: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

Featured APIs & Mashups

Page 7: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

APIs protocols & styles

Page 8: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

REST is an architectural style

Gorthic Architectural Style

Page 9: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

REST v.s HTTP

Gorthic architectural style

REST HTTP

Page 10: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Client/Server Model

Page 11: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

HTTP is resource-centric

Page 12: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Resource Identifier, Methods & Representations

Page 13: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Hypermedia: Association & Composition

Page 14: REST Architectural Style: A Detail Explain

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 onserver other than data retrieval.

Idempotent Any side-effects on the server of several identicalidempotent methods are the same as theside-effects of one single method.

Cacheable Explain in more details later. . .

Page 15: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Intermediaries - Cache

A new request for a cached resource can be returnedimmediately by intermediary caches.

Page 16: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Intermediaries - Proxy & Gateway

Proxyan intermediary selected by a client, to provideinterfaces to services like data translation,performance enhancement, or security protection.

Gatewayan intermediary imposed by the network or originserver to provide an interface encapsulation ofother services, for data translation, performanceenhancement, or security enforcement.

Page 17: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Stateless

HTTP Requests are stateless, which means each request isindependent from the others.

Page 18: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Stateless

HTTP Requests are stateless, which means each request isindependent from the others.

intermediaries only need to work on a single interactionwithout knowing the entire topology

Page 19: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST

REST Architectural Style

REpresentational State TransferThe representation returned by the server placesor transfers the client from state to state.

REST Architectural Style. . . a set of architectural constraints that, whenapplied as a whole, emphasizes scalability ofcomponent interactions, generality of interfaces,independent deployment of components,intermediary components to reduce interactionlatency, enforce security, and encapsulate legacysystems.

Roy T. Fielding

Page 20: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST

REST Architectural Constraints

Page 21: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST

REST Architectural Elements

Page 22: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST

RESTful v.s SOAP

Page 23: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Specification

JAX-RS: The Java™API for RESTful Web Services

Page 24: REST Architectural Style: A Detail Explain

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;}

Page 25: REST Architectural Style: A Detail Explain

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;}

}

Page 26: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Implementation

Open Sources RESTful Web Service Implementation of JAX-RS

Jersey - Sun reference implementationRESTEasy - JBossRestlet

Page 27: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Discussion

REST Motivation

ScalabilityPerfomanceReduce Payload & LatencyDynamic Component Connectors

Page 28: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Discussion

REST v.s the rest

SOA ?Servlet & JSP ?Javascript ?

Page 29: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Final word

Web APIs Worldwide

Page 30: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Final word

Web APIs Featured Regions

Page 31: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Final word

Web APIs Vietnam

Page 32: REST Architectural Style: A Detail Explain

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Final word

THANK YOU *-*