際際滷

際際滷Share a Scribd company logo
REST APIs
Overview and Jersey / JAX-RS Intro
Andy Pemberton
RJUG, May 2014
Background
Background
 Front-end guy
 Middleware Java guy
 Agilist, learner, polyglot
 Family guy
REST in a Page
 Architectural Style  a set of constraints
 Nouns and Verbs
 HTTP-Based
 Roy Fielding  U. C. Irvine
 Representational State Transfer
 Not SOAP
Constraint: Nouns and Verbs
Constraint: Nouns and Verbs
 Nouns
 Your business model
 Account, Plan, Cat, Dog, Foo, Bar 
 Verbs
 HTTP-Defined (RFC-2616)
 GET, PUT, POST, DELETE
 TRACE, OPTIONS, HEAD
 PATCH
Examples
BAD
GET /fetch-accounts
GET /create-payment
POST /cancel-payment
GOOD
GET /accounts
POST /payment
DELETE /payments/{id}
Verbs
 GET (idempotent)
 PUT (idempotent)
 POST
 DELETE
 PATCH (draft)
 TRACE, OPTIONS, HEAD
Specs and Stuff
 JAX-RS  Java API for RESTful Web Services
 JSR-311  JAX-RS 1.0
 JSR-339  JAX-RS 2.0
 Dependency Injection
 Bean Validation
 Client API enhancements
Web & Mobile Friendly
Frameworks
 .NET  asp.net web API
 Others: Ruby, NodeJS, Scala, Python
 Java
 Glassfish (Oracle)  Jersey
 JBoss  RESTEasy
 Restlet
 Dropwizard
Jersey
 Oracle Reference Implementation
 JSR-311, JSR-339
 Extensions
 Examples Projects
OK - code time, but you got the idea
Other Constraints
 Client-Server
 Hypermedia contracts (links, hrefs)
 Stateless
API Documentation
 wsdl 2.0, wadl
 apiary.io
 enunciate
 swagger
 Mashery I/O Docs
RJUG - REST API / JAX-RS Overview
Swagger
 Swagger Core
 Annotations
 JAX-RS integration
 Schema generations
 Swagger UI
Advanced REST
 Partial representations
api.foobar.com/addresses?select=postalCode
 Resource linking / expansion
api.foobar.com/customers/1234?expand=accounts
 API Versioning
Fin
 References
 http://code.google.com/p/implementing-rest/wiki/ByLanguage
 https://stormpath.com/blog/linking-and-resource-expansion-
rest-api-tips/
 http://www.mashery.com/product/io-docs

More Related Content

RJUG - REST API / JAX-RS Overview

Editor's Notes

  • #9: POST != create and PUT != update
  • #12: Good Referencehttp://code.google.com/p/implementing-rest/wiki/ByLanguage