Click here to load reader
View
1
Download
0
Embed Size (px)
RESTEasy JAX-RS
RESTFul Web Services for Java
4.3.0.Final
iii
Preface ............................................................................................................................. xi
1. Overview ...................................................................................................................... 1
2. License ........................................................................................................................ 3
3. Installation/Configuration ............................................................................................ 5
3.1. RESTEasy modules in WildFly ............................................................................ 5
3.1.1. Other RESTEasy modules ........................................................................ 6
3.1.2. Upgrading RESTEasy within WildFly ......................................................... 7
3.2. Deploying a RESTEasy application to WildFly ...................................................... 7
3.3. Deploying to other servlet containers ................................................................... 8
3.3.1. Servlet 3.0 containers .............................................................................. 8
3.3.2. Older servlet containers ............................................................................ 9
3.4. Configuration .................................................................................................... 10
3.4.1. Using MicroProfileConfig ......................................................................... 11
3.4.2. Configuration MicroProfile Config ............................................................ 12
3.5. Configuration switches ...................................................................................... 12
3.6. javax.ws.rs.core.Application ............................................................................... 16
3.7. RESTEasy as a ServletContextListener .............................................................. 18
3.8. RESTEasy as a Servlet Filter ............................................................................ 18
3.9. Client side ........................................................................................................ 19
4. Using @Path and @GET, @POST, etc. ...................................................................... 21
4.1. @Path and regular expression mappings ........................................................... 22
5. @PathParam .............................................................................................................. 25
5.1. Advanced @PathParam and Regular Expressions .............................................. 26
5.2. @PathParam and PathSegment ........................................................................ 26
6. @QueryParam ............................................................................................................ 29
7. @HeaderParam .......................................................................................................... 31
7.1. HeaderDelegates .............................................................................................. 31
8. Linking resources ...................................................................................................... 35
8.1. Link Headers .................................................................................................... 35
8.2. Atom links in the resource representations ......................................................... 35
8.2.1. Configuration .......................................................................................... 35
8.2.2. Your first links injected ........................................................................... 35
8.2.3. Customising how the Atom links are serialised ......................................... 38
8.2.4. Specifying which JAX-RS methods are tied to which resources .................. 38
8.2.5. Specifying path parameter values for URI templates ................................. 39
8.2.6. Securing entities .................................................................................... 42
8.2.7. Extending the UEL context ..................................................................... 42
8.2.8. Resource facades .................................................................................. 44
9. @MatrixParam ............................................................................................................ 47
10. @CookieParam ........................................................................................................ 49
11. @FormParam ........................................................................................................... 51
12. @Form ..................................................................................................................... 53
13. Improved @…Param annotations ............................................................................ 57
14. Optional parameter types ........................................................................................ 59
RESTEasy JAX-RS
iv
15. @DefaultValue .......................................................................................................... 61
16. @Encoded and encoding ......................................................................................... 63
17. @Context ................................................................................................................. 65
18. JAX-RS Resource Locators and Sub Resources ..................................................... 67
19. Resources metadata configuration .......................................................................... 71
20. JAX-RS Content Negotiation .................................................................................... 75
20.1. URL-based negotiation .................................................................................... 76
20.2. Query String Parameter-based negotiation ........................................................ 77
21. Content Marshalling/Providers ................................................................................. 79
21.1. Default Providers and default JAX-RS Content Marshalling ................................ 79
21.2. Content Marshalling with @Provider classes ..................................................... 80
21.3. Providers Utility Class ..................................................................................... 81
21.4. Configuring Document Marshalling ................................................................... 84
21.5. Text media types and character sets ................................................................ 85
22. JAXB providers ........................................................................................................ 87
22.1. JAXB Decorators ............................................................................................ 88
22.2. Pluggable JAXBContext's with ContextResolvers .............................................. 89
22.3. JAXB + XML provider ...................................................................................... 90
22.3.1. @XmlHeader and @Stylesheet ............................................................. 90
22.4. JAXB + JSON provider .................................................................................... 92
22.5. JAXB + FastinfoSet provider ............................................................................ 94
22.6. Arrays and Collections of JAXB Objects ........................................................... 94
22.6.1. Retrieving Collections on the client side ................................................. 96
22.6.2. JSON and JAXB Collections/arrays ....................................................... 97
22.7. Maps of JAXB Objects .................................................................................... 98
22.7.1. Retrieving Maps on the client side ....................................................... 101
22.7.2. JSON and JAXB maps ....................................................................... 101
22.8. Interfaces, Abstract Classes, and JAXB .......................................................... 102
22.9. Configurating JAXB Marshalling ..................................................................... 103
23. RESTEasy Atom Support ....................................................................................... 105
23.1. RESTEasy Atom API and Provider ................................................................. 105
23.2. Using JAXB with the Atom Provider ............................................................... 106
24. JSON Support via Jackson .................................................................................... 109
24.1. Using Jackson 1.9.x Outside of WildFly .......................................................... 109
24.2. Using Jackson 1.9.x Inside WildFly 8 ............................................................. 109
24.3. Using Jackson 2 Outside of WildFly ............................................................... 109
24.4. Using Jackson 2 In