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.

Jax rstalk

337 views

Published on

Slides for my presentation to the Queensland JVM group

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Jax rstalk

  1. 1. RESTful Web Services with JAX-RS 2 Benjamin Morgan @benedwinmorgan http://badness10000.blogspot.com.au/
  2. 2. Talk Overview ● History of JAX-RS ● JAX-RS intro ● New Features in JAX-RS 2 ● Client API ● Filters and Interceptors ● Asynchronous Support
  3. 3. What is not covered ● ● ● ● Configuration of JAX-RS services in a container Configuration of JAX-RS with DI frameworks (i.e. spring) Configuration of JAX-RS servlet beyond a basic level Detailed coverage of JAX-RS api i.e. Content routing, different content types etc.
  4. 4. History of JAX-RS ● JSR 311 2007 ● JSR 339 for JAX-RS 2 released 2013 ● ● Multiple implementations (Jersey, RESTeasy, CXF and others) Shipped with EE app servers
  5. 5. Why JAX-RS ● ● ● Ties in with Java EE so you get automatic exposure in a EE container Standard so you can switch implementations Easy to build well behaved services, particularly around response codes other than 200
  6. 6. Quick intro to JAX-RS services ● ● ● ● Annotation driven i.e. @GET, @Path, @Produces Annotations are scanned by container or configured through a servlet parameter Service beans are not necessarily singletons Many of the code examples are based on or inspired by examples that ship with Jersey
  7. 7. Code ● web.xml ● MyResource ● JaxRSApplication
  8. 8. Client Api ● JAX-RS 1 was server side only API ● JAX-RS 2 client API aims to be ● Fluent using builder pattern ● 'Inspired' by Jersey 1 client API ● Uncertain about how to unit test this code
  9. 9. Code ● MyResourceClient
  10. 10. Filters and Interceptors ● ● ● ● Filters can modify entire request Interceptors are intended to modify the entity (payload) only Can apply to client or server API Usually a few useful ones ship with implementations such as Logging Filters
  11. 11. Code ● JaxRSApplication ● PoweredByResponseFilter ● MyResourceClient – Get demonstrates registration of filters on client and target
  12. 12. Async Support ● Support for Asynchronous usage on both the client and server ● Need to set async-supported in the servlet ● @Suspended injects an AsyncResponse ● ● Response is written using the AsyncResponse object, request thread is returned to the pool Support for chunked output
  13. 13. Code ● DelayedAsyncResource ● AsyncResouce
  14. 14. Code ● DelayedAsyncResource ● AsyncResouce
  15. 15. My Questions ● Tuning thread pools? ● Async servlet support ● Testing client api ● Thread safety of Client factory
  16. 16. Thanks for listening ● ● Code for the talk on Git https://github.com/nebnagrom/qldjvmJaxRs2 Slideshare http://www.slideshare.net/benjaminedwinmorga n/jax-rstalk ● Podcast - http://hackandheckle.com/ ● Twitter - @benedwinmorgan ● Blog - http://badness10000.blogspot.com.au/

×