Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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
–...
Constraint: Nouns and Verbs
Constraint: Nouns and Verbs
• Nouns
– Your business model
• Account, Plan, Cat, Dog, Foo, Bar 
• Verbs
– HTTP-Defined (RF...
Examples
BAD
GET /fetch-accounts
GET /create-payment
POST /cancel-payment
GOOD
GET /accounts
POST /payment
DELETE /payment...
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 In...
Web & Mobile Friendly
Frameworks
• .NET – asp.net web API
• Others: Ruby, NodeJS, Scala, Python
• Java
– Glassfish (Oracle) – Jersey
– JBoss – R...
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
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.foob...
Fin
• References
– http://code.google.com/p/implementing-rest/wiki/ByLanguage
– https://stormpath.com/blog/linking-and-res...
RJUG - REST API / JAX-RS Overview
Upcoming SlideShare
Loading in …5
×

RJUG - REST API / JAX-RS Overview

874 views

Published on

An overview of JAX-RS, Jersey, and REST API development

Published in: Technology
  • Be the first to comment

  • Be the first to like this

RJUG - REST API / JAX-RS Overview

  1. 1. REST APIs Overview and Jersey / JAX-RS Intro Andy Pemberton RJUG, May 2014
  2. 2. Background
  3. 3. Background • Front-end guy • Middleware Java guy • Agilist, learner, polyglot • Family guy 
  4. 4. 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
  5. 5. Constraint: Nouns and Verbs
  6. 6. 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
  7. 7. Examples BAD GET /fetch-accounts GET /create-payment POST /cancel-payment GOOD GET /accounts POST /payment DELETE /payments/{id}
  8. 8. Verbs • GET (idempotent) • PUT (idempotent) • POST • DELETE • PATCH (draft) • TRACE, OPTIONS, HEAD
  9. 9. 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
  10. 10. Web & Mobile Friendly
  11. 11. Frameworks • .NET – asp.net web API • Others: Ruby, NodeJS, Scala, Python • Java – Glassfish (Oracle) – Jersey – JBoss – RESTEasy – Restlet – Dropwizard
  12. 12. Jersey • Oracle Reference Implementation – JSR-311, JSR-339 • Extensions • Examples Projects
  13. 13. OK - code time, but you got the idea…
  14. 14. Other Constraints • Client-Server • Hypermedia contracts (links, hrefs) • Stateless
  15. 15. API Documentation • wsdl 2.0, wadl • apiary.io • enunciate • swagger – Mashery I/O Docs
  16. 16. Swagger • Swagger Core – Annotations – JAX-RS integration – Schema generations • Swagger UI
  17. 17. Advanced REST • Partial representations api.foobar.com/addresses?select=postalCode • Resource linking / expansion api.foobar.com/customers/1234?expand=accounts • API Versioning
  18. 18. 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

×