Download Jersey 2.1 User Guide
Transcript
Jersey 2.1 User Guide 6.4. Conditional GETs and Returning 304 (Not Modified) Responses ................................. 60 7. JAX-RS Entity Providers ................................................................................................ 62 7.1. Introduction ....................................................................................................... 62 7.2. How to Write Custom Entity Providers ................................................................... 62 7.2.1. MessageBodyWriter .................................................................................. 63 7.2.2. MessageBodyReader ................................................................................. 67 7.3. Entity Provider Selection ...................................................................................... 69 7.4. Jersey MessageBodyWorkers API .................................................................... 72 7.5. Default Jersey Entity Providers ............................................................................. 74 8. Support for Common Media Type Representations .............................................................. 75 8.1. JSON ................................................................................................................ 75 8.1.1. Approaches to JSON Support ..................................................................... 75 8.1.2. MOXy .................................................................................................... 78 8.1.3. Java API for JSON Processing (JSON-P) ...................................................... 81 8.1.4. Jackson ................................................................................................... 82 8.1.5. Jettison ................................................................................................... 84 8.1.6. @JSONP - JSON with Padding Support ........................................................ 88 8.2. XML ................................................................................................................ 90 8.2.1. Low level XML support ............................................................................ 90 8.2.2. Getting started with JAXB ......................................................................... 91 8.2.3. POJOs .................................................................................................... 93 8.2.4. Using custom JAXBContext ....................................................................... 94 8.2.5. MOXy .................................................................................................... 95 8.3. Multipart ........................................................................................................... 96 8.3.1. Overview ................................................................................................ 96 8.3.2. Client ..................................................................................................... 97 8.3.3. Server .................................................................................................... 99 9. Filters and Interceptors ................................................................................................. 102 9.1. Introduction ..................................................................................................... 102 9.2. Filters ............................................................................................................. 102 9.2.1. Server filters .......................................................................................... 102 9.2.2. Client fillers .......................................................................................... 105 9.3. Interceptors ...................................................................................................... 105 9.4. Filter and interceptor execution order .................................................................... 107 9.5. Name binding ................................................................................................... 109 9.6. Dynamic binding .............................................................................................. 111 9.7. Priorities .......................................................................................................... 113 10. Asynchronous Services and Clients ............................................................................... 114 10.1. Asynchronous Server API ................................................................................. 114 10.1.1. Asynchronous Server-side Callbacks ......................................................... 116 10.1.2. Chunked Output .................................................................................... 118 10.2. Client API ...................................................................................................... 120 10.2.1. Asynchronous Client Callbacks ............................................................... 120 10.2.2. Chunked input ...................................................................................... 122 11. URIs and Links ......................................................................................................... 124 11.1. Building URIs ................................................................................................. 124 11.2. Resolve and Relativize ..................................................................................... 125 11.3. Link .............................................................................................................. 125 12. Programmatic API for Building Resources ..................................................................... 127 12.1. Introduction .................................................................................................... 127 12.2. Programmatic Hello World example ................................................................... 127 12.2.1. Deployment of programmatic resources ..................................................... 129 12.3. Additional examples ........................................................................................ 130 12.4. Model processors ............................................................................................ 131 iv