rest architectural style: a detail explain

Post on 01-Dec-2014

468 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

A presentation about REST architectural principles at BarcampSaigon Winter 2011

TRANSCRIPT

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST Architectural Style: A Detail Explain

Cao Duc Nguyennguyen.cao-duc@hp.com

Software Designer

December 12, 2011

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

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

The Importance of APIs in Web Development

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

APIs Timeline on ProgrammableWeb

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

APIs Timeline on ProgrammableWeb in more details

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

Featured APIs & Mashups

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Web APIs

APIs protocols & styles

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

REST is an architectural style

Gorthic Architectural Style

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

REST v.s HTTP

Gorthic architectural style

REST HTTP

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Client/Server Model

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

HTTP is resource-centric

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Resource Identifier, Methods & Representations

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Hypermedia: Association & Composition

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. . .

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.

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.

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

HTTP

Stateless

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

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

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

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST

REST Architectural Constraints

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST

REST Architectural Elements

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

REST

RESTful v.s SOAP

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Specification

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

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

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

}

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

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Discussion

REST Motivation

ScalabilityPerfomanceReduce Payload & LatencyDynamic Component Connectors

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Discussion

REST v.s the rest

SOA ?Servlet & JSP ?Javascript ?

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Final word

Web APIs Worldwide

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Final word

Web APIs Featured Regions

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Final word

Web APIs Vietnam

Introduction REST Fundamentals Java Open Source RESTful Web Services Conclusion

Final word

THANK YOU *-*

top related