Click here to load reader

RESTEasy JAX-RS - JBoss ... JAX-RS 2.0 (JSR-339) and JAX-RS 2.1 (JSR-370), are JCP specifications that provide a Java API for RESTful Web Services over the HTTP protocol. RESTEasy

  • View
    2

  • Download
    0

Embed Size (px)

Text of RESTEasy JAX-RS - JBoss ... JAX-RS 2.0 (JSR-339) and JAX-RS 2.1 (JSR-370), are JCP specifications...

  • RESTEasy JAX-RS

    RESTFul Web Services for Java

    3.6.2.Final

  • iii

    Preface ............................................................................................................................. ix

    1. Overview ...................................................................................................................... 1

    2. License ........................................................................................................................ 3

    3. Installation/Configuration ............................................................................................ 5

    3.1. RESTEasy modules in WildFly ............................................................................ 5

    3.1.1. Other RESTEasy modules ........................................................................ 7

    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 .............................................................................. 9

    3.3.2. Older servlet containers ............................................................................ 9

    3.4. Configuration switches ...................................................................................... 10

    3.5. javax.ws.rs.core.Application ............................................................................... 14

    3.6. RESTEasy as a ServletContextListener .............................................................. 15

    3.7. RESTEasy as a Servlet Filter ............................................................................ 16

    3.8. Client side ........................................................................................................ 16

    4. Using @Path and @GET, @POST, etc. ...................................................................... 19

    4.1. @Path and regular expression mappings ........................................................... 20

    4.2. JAX-RS 2.0 Matching Algorithm ......................................................................... 21

    5. @PathParam .............................................................................................................. 23

    5.1. Advanced @PathParam and Regular Expressions .............................................. 24

    5.2. @PathParam and PathSegment ........................................................................ 24

    6. @QueryParam ............................................................................................................ 27

    7. @HeaderParam .......................................................................................................... 29

    8. Linking resources ...................................................................................................... 31

    8.1. Link Headers .................................................................................................... 31

    8.2. Atom links in the resource representations ......................................................... 31

    8.2.1. Configuration .......................................................................................... 31

    8.2.2. Your first links injected ........................................................................... 31

    8.2.3. Customising how the Atom links are serialised ......................................... 34

    8.2.4. Specifying which JAX-RS methods are tied to which resources .................. 34

    8.2.5. Specifying path parameter values for URI templates ................................. 35

    8.2.6. Securing entities .................................................................................... 38

    8.2.7. Extending the UEL context ..................................................................... 38

    8.2.8. Resource facades .................................................................................. 40

    9. @MatrixParam ............................................................................................................ 43

    10. @CookieParam ........................................................................................................ 45

    11. @FormParam ........................................................................................................... 47

    12. @Form ..................................................................................................................... 49

    13. Improved @…Param annotations ............................................................................ 53

    14. @DefaultValue .......................................................................................................... 55

    15. @Encoded and encoding ......................................................................................... 57

    16. @Context ................................................................................................................. 59

    17. JAX-RS Resource Locators and Sub Resources ..................................................... 61

  • RESTEasy JAX-RS

    iv

    18. Resources metadata configuration .......................................................................... 65

    19. JAX-RS Content Negotiation .................................................................................... 69

    19.1. URL-based negotiation .................................................................................... 70

    19.2. Query String Parameter-based negotiation ........................................................ 71

    20. Content Marshalling/Providers ................................................................................. 73

    20.1. Default Providers and default JAX-RS Content Marshalling ................................ 73

    20.2. Content Marshalling with @Provider classes ..................................................... 74

    20.3. Providers Utility Class ..................................................................................... 75

    20.4. Configuring Document Marshalling ................................................................... 78

    20.5. Text media types and character sets ................................................................ 79

    21. JAXB providers ........................................................................................................ 81

    21.1. JAXB Decorators ............................................................................................ 82

    21.2. Pluggable JAXBContext's with ContextResolvers .............................................. 83

    21.3. JAXB + XML provider ...................................................................................... 84

    21.3.1. @XmlHeader and @Stylesheet ............................................................. 84

    21.4. JAXB + JSON provider .................................................................................... 86

    21.5. JAXB + FastinfoSet provider ............................................................................ 90

    21.6. Arrays and Collections of JAXB Objects ........................................................... 90

    21.6.1. Retrieving Collections on the client side ................................................. 93

    21.6.2. JSON and JAXB Collections/arrays ....................................................... 94

    21.7. Maps of JAXB Objects .................................................................................... 95

    21.7.1. Retrieving Maps on the client side ......................................................... 97

    21.7.2. JSON and JAXB maps ......................................................................... 98

    21.7.3. Possible Problems with Jettison Provider ............................................... 98

    21.8. Interfaces, Abstract Classes, and JAXB ............................................................ 99

    21.9. Configurating JAXB Marshalling ....................................................................... 99

    22. RESTEasy Atom Support ....................................................................................... 101

    22.1. RESTEasy Atom API and Provider ................................................................. 101

    22.2. Using JAXB with the Atom Provider ............................................................... 102

    23. JSON Support via Jackson .................................................................................... 105

    23.1. Using Jackson 1.9.x Outside of WildFly .......................................................... 105

    23.2. Using Jackson 1.9.x Inside WildFly 8 ............................................................. 105

    23.3. Using Jackson 2 Outside of WildFly ............................................................... 105

    23.4. Using Jackson 2 Inside WildFly 9 and above .................................................. 106

    23.5. Additional RESTEasy Specifics ...................................................................... 106

    23.6. Possible Conflict With JAXB Provider ............................................................. 107

    23.7. JSONP Support .........................................

Search related