JBoss Enterprise Web Platform 5

RESTEasy Reference Guide

for Use with JBoss Enterprise Web Platform

Edition 5.1.1

Red Hat Documentation Group

Legal Notice

Copyright © 2011 Red Hat, Inc.
This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack Logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.

Abstract

This book is a reference guide for using RESTEasy with JBoss Enterprise Web Platform 5 and its patch releases.
Preface
1. Document Conventions
1.1. Typographic Conventions
1.2. Pull-quote Conventions
1.3. Notes and Warnings
2. Getting Help and Giving Feedback
2.1. Do You Need Help?
2.2. Give us Feedback
1. Overview
2. Installation/Configuration
2.1. javax.ws.rs.core.Application
2.2. RESTEasyLogging
3. Using @Path and @GET, @POST, etc.
3.1. @Path and regular expression mappings
4. @PathParam
4.1. Advanced @PathParam and Regular Expressions
4.2. @PathParam and PathSegment
5. @QueryParam
6. @HeaderParam
7. @MatrixParam
8. @CookieParam
9. @FormParam
10. @Form
11. @DefaultValue
12. @Encoded and encoding
13. @Context
14. JAX-RS Resource Locators and Sub Resources
15. JAX-RS Content Negotiation
16. Content Marshalling/Providers
16.1. Default Providers and default JAX-RS Content Marshalling
16.2. Content Marshalling with @Provider classes
16.3. Providers Utility Class
17. JAXB Providers
17.1. JAXB Decorators
17.2. Pluggable JAXBContexts with ContextResolvers
17.3. JAXB and XML provider
17.3.1. @XmlHeader and @Stylesheet
17.4. JAXB and JSON provider
17.5. JAXB and FastinfoSet provider
17.6. Arrays and Collections of JAXB Objects
17.6.1. JSON and JAXB Collections/Arrays
17.7. Maps of JAXB Objects
17.7.1. JSON and JAXB maps
17.7.2. Possible Problems with Jettison Provider
17.8. Interfaces, Abstract Classes, and JAXB
18. RESTEasy Atom Support
18.1. RESTEasy Atom API and Provider
18.2. Using JAXB with the Atom Provider
18.3. Atom support through Apache Abdera
18.3.1. Abdera and Maven
18.3.2. Using the Abdera Provider
19. JSON Support via Jackson
19.1. Possible Conflict With JAXB Provider
20. Multipart Providers
20.1. Input with multipart/mixed
20.2. java.util.List with multipart data
20.3. Input with multipart/form-data
20.4. java.util.Map with multipart/form-data
20.5. Input with multipart/related
20.6. Output with multipart
20.7. Multipart Output with java.util.List
20.8. Output with multipart/form-data
20.9. Multipart FormData Output with java.util.Map
20.10. Output with multipart/related
20.11. @MultipartForm and POJOs
20.12. XML-binary Optimized Packaging (Xop)
21. YAML Provider
22. String marshalling for String based @*Param
23. Responses using javax.ws.rs.core.Response
24. Exception Handling
24.1. Exception Mappers
24.2. RESTEasy Built-in Internally-Thrown Exceptions
24.3. Overriding Resteasy Builtin Exceptions
25. Configuring Individual JAX-RS Resource Beans
26. GZIP Compression/Decompression
27. RESTEasy Caching Features
27.1. @Cache and @NoCache Annotations
27.2. Client "Browser" Cache
27.3. Local Server-Side Response Cache
28. Interceptors
28.1. MessageBodyReader/Writer Interceptors
28.2. PreProcessInterceptor
28.3. PostProcessInterceptors
28.4. ClientExecutionInterceptors
28.5. Binding Interceptors
28.6. Registering Interceptors
28.7. Interceptor Ordering and Precedence
28.7.1. Custom Precedence
29. Asynchronous HTTP Request Processing
29.1. Tomcat 6 and JBoss 4.2.3 Support
29.2. Servlet 3.0 Support
29.3. JBossWeb, JBoss AS 5.0.x Support
30. Asynchronous Job Service
30.1. Using Async Jobs
30.2. Oneway: Fire and Forget
30.3. Setup and Configuration
31. Embedded Container
32. Server-side Mock Framework
33. Securing JAX-RS and RESTeasy
34. EJB Integration
35. Spring Integration
35.1. Basic Integration
35.2. Spring MVC Integration
36. Guice 1.0 Integration
37. Client Framework
37.1. Abstract Responses
37.2. Sharing an interface between client and server
37.3. Client error handling
37.4. Manual ClientRequest API
38. Maven and RESTEasy
39. JBoss 5.x Integration
40. Migration from older versions
40.1. Migrating from 1.0.x and 1.1-RC1
A. Revision History