Links: Table of Contents | Single HTML

Jersey 2.0 User Guide


Table of Contents

Preface
1. Getting Started
1.1. Creating a New Project from Maven Archetype
1.2. Exploring the Newly Created Project
1.3. Running the Project
1.4. Creating a JavaEE Web Application
1.5. Exploring Other Jersey Examples
2. Modules and dependencies
2.1. Java SE Compatibility
2.2. Introduction to Jersey dependencies
2.3. Common Jersey Use Cases
2.3.1. Servlet based application on Glassfish
2.3.2. Servlet based server-side application
2.3.3. Client application on JDK
2.3.4. Served side application on supported container
2.4. List of modules
3. JAX-RS Application, Resources and Sub-Resources
3.1. Root Resource Classes
3.1.1. @Path
3.1.2. @GET, @PUT, @POST, @DELETE, ... (HTTP Methods)
3.1.3. @Produces
3.1.4. @Consumes
3.2. Parameter Annotations (@*Param)
3.3. Sub-resources
3.4. Life-cycle of Root Resource Classes
3.5. Rules of Injection
3.6. Use of @Context
3.7. Programmatic resource model
4. Deploying a RESTful Web Service
4.1. Auto-Discoverable Features
4.1.1. Configuring the Feature Auto-discovery mechanism
5. Client API
5.1. Uniform Interface Constraint
5.2. Ease of use and reusing JAX-RS artifacts
5.3. Overview of the Client API
5.3.1. Getting started with the client API
5.3.2. Creating and configuring a Client instance
5.3.3. Targeting a web resource
5.3.4. Identifying resource on WebTarget
5.3.5. Invoking a HTTP request
5.3.6. Example summary
5.4. Java instances and types for representations
5.4.1. Adding support for new representations
5.5. Client Transport Connectors
5.6. Using client request and response filters
5.7. Securing a Client
5.7.1. HTTP Basic Authentication Support
6. Representations and Responses
6.1. Representations and Java Types
6.2. Building Responses
6.3. WebApplicationException and Mapping Exceptions to Responses
6.4. Conditional GETs and Returning 304 (Not Modified) Responses
7. JAX-RS Entity Providers
7.1. Introduction
7.2. How to Write Custom Entity Providers
7.2.1. MessageBodyWriter
7.2.2. MessageBodyReader
7.3. Entity Provider Selection
7.4. Jersey MessageBodyWorkers API
7.5. Default Jersey Entity Providers
8. Support for Common Media Type Representations
8.1. JSON
8.1.1. Approaches to JSON Support
8.1.2. MOXy
8.1.3. Java API for JSON Processing (JSON-P)
8.1.4. Jackson
8.1.5. Jettison
8.1.6. @JSONP - JSON with Padding Support
8.2. XML
8.2.1. Low level XML support
8.2.2. Getting started with JAXB
8.2.3. POJOs
8.2.4. Using custom JAXBContext
8.2.5. MOXy
8.3. Multipart
8.3.1. Overview
8.3.2. Client
8.3.3. Server
9. Filters and Interceptors
9.1. Introduction
9.2. Filters
9.2.1. Server filters
9.2.2. Client fillers
9.3. Interceptors
9.4. Filter and interceptor execution order
9.5. Name binding
9.6. Dynamic binding
9.7. Priorities
10. Asynchronous Services and Clients
10.1. Asynchronous Server API
10.1.1. Asynchronous Server-side Callbacks
10.1.2. Chunked Output
10.2. Client API
10.2.1. Asynchronous Client Callbacks
10.2.2. Chunked input
11. URIs and Links
11.1. Building URIs
11.2. Resolve and Relativize
11.3. Link
12. Programmatic API for Building Resources
12.1. Introduction
12.2. Programmatic Hello World example
12.2.1. Deployment of programmatic resources
12.3. Additional examples
12.4. Model processors
13. Server-Sent Events (SSE) Support
13.1. What are Server-Sent Events
13.2. When to use Server-Sent Events
13.3. Jersey Server-Sent Events API
13.4. Implementing SSE support in a JAX-RS resource
13.4.1. Simple SSE resource method
13.4.2. Broadcasting with Jersey SSE
13.5. Consuming SSE events with Jersey clients
13.5.1. Reading SSE events with EventInput
13.5.2. Asynchronous SSE processing with EventSource
14. Security
14.1. Securing server
14.1.1. SecurityContext
14.1.2. Authorization - securing resources
14.2. Client Security
14.3. OAuth
15. WADL Support
15.1. WADL introduction
15.2. Configuration
15.3. Extended WADL support
16. Bean Validation Support
16.1. Bean Validation Dependencies
16.2. Enabling Bean Validation in Jersey
16.3. Configuring Bean Validation Support
16.4. Validating JAX-RS resources and methods
16.4.1. Constraint Annotations
16.4.2. Annotation constraints and Validators
16.4.3. Entity Validation
16.4.4. Annotation Inheritance
16.5. @ValidateOnExecution
16.6. Injecting
16.7. Error Reporting
16.7.1. ValidationError
16.8. Example
17. MVC Templates
17.1. Dependencies
17.2. Registration and Configuration
17.3. Explicit vs. Implicit View Templates
17.3.1. Viewable - Explicit View Templates
17.3.2. @Template - Implicit View Templates
17.4. JSP
17.5. Custom Templating Engines
17.6. Other Examples
18. Jersey Test Framework
18.1. Basics
18.2. Supported Containers
18.3. Advanced features
18.3.1. JerseyTest Features
18.3.2. External container
18.3.3. Test Client configuration
18.3.4. Accessing the logged test records programmatically
19. Building and Testing Jersey
19.1. Checking Out the Source
19.2. Building the Source
19.3. Testing
19.4. Using NetBeans
20. Migrating from Jersey 1.x
20.1. Server API
20.1.1. Injecting custom objects
20.1.2. ResourceConfig Reload
20.1.3. MessageBodyReaders and MessageBodyWriters ordering
20.2. Migrating Jersey Client API
20.2.1. Making a simple client request
20.2.2. Registering filters
20.2.3. Setting "Accept" header
20.2.4. Attaching entity to request
20.2.5. Setting SSLContext and/or HostnameVerifier
A. Configuration Properties
A.1. Common (client/server) configuration properties
A.2. Server configuration properties
A.3. Client configuration properties

List of Examples

3.1. Simple hello world root resource class
3.2. Specifying URI path parameter
3.3. PUT method
3.4. Specifying output MIME type
3.5. Using multiple output MIME types
3.6. Server-side content negotiation
3.7. Specifying input MIME type
3.8. Query parameters
3.9. Custom Java type for consuming request parameters
3.10. Processing POSTed HTML form
3.11. Obtaining general map of URI path and/or query parameters
3.12. Obtaining general map of header parameters
3.13. Obtaining general map of form parameters
3.14. Example of the bean which will be used as @BeanParam
3.15. Injection of MyBeanParam as a method parameter:
3.16. Injection of more beans into one resource methods:
3.17. Sub-resource methods
3.18. Sub-resource locators
3.19. Sub-resource locators with empty path
3.20. Sub-resource locators returning sub-type
3.21. Sub-resource locators created from classes
3.22. Sub-resource locators returning resource model
3.23. Injection
3.24. Wrong injection into a singleton scope
3.25. Injection of proxies into singleton
3.26. Example of possible injections
4.1. Deployment agnostic application model
4.2. Reusing Jersey implementation in your custom application model
4.3. Deployment of a JAX-RS application using @ApplicationPath with Servlet 3.0
4.4. Configuration of maven-war-plugin in pom.xml with Servlet 3.0
4.5. Deployment of a JAX-RS application using web.xml with Servlet 3.0
4.6. Deployment of your application using Jersey specific servlet
4.7. Using Jersey specific servlet without an application model instance
5.1. POST request with form parameters
5.2. Using JAX-RS Client API
5.3. Using JAX-RS Client API fluently
6.1. Using File with a specific media type to produce a response
6.2. Returning 201 status code and adding Location header in response to POST request
6.3. Adding an entity body to a custom response
6.4. Throwing exceptions to control response
6.5. Application specific exception implementation
6.6. Mapping generic exceptions to responses
6.7. Conditional GET support
7.1. Example resource class
7.2. MyBean entity class
7.3. MessageBodyWriter example
7.4. Example of assignment of annotations to a response entity
7.5. Client code testing MyBeanMessageBodyWriter
7.6. Result of MyBeanMessageBodyWriter test
7.7. MessageBodyReader example
7.8. Testing MyBeanMessageBodyReader
7.9. Result of testing MyBeanMessageBodyReader
7.10. MessageBodyReader registered on a JAX-RS client
7.11. Result of client code execution
7.12. Usage of MessageBodyWorkers interface
8.1. Simple JAXB bean implementation
8.2. JAXB bean used to generate JSON representation
8.3. Tweaking JSON format using JAXB
8.4. JAXB bean creation
8.5. Constructing a JsonObject (JSON-Processing)
8.6. Constructing a JSONObject (Jettison)
8.7. MoxyJsonConfig - Setting properties.
8.8. ContextResolver<MoxyJsonConfig>
8.9. Setting properties for MOXy providers into Configurable
8.10. Building client with MOXy JSON feature enabled.
8.11. Creating JAX-RS application with MOXy JSON feature enabled.
8.12. Building client with JSON-Processing JSON feature enabled.
8.13. Creating JAX-RS application with JSON-Processing JSON feature enabled.
8.14. ContextResolver<ObjectMapper>
8.15. Building client with Jackson JSON feature enabled.
8.16. Creating JAX-RS application with Jackson JSON feature enabled.
8.17. JAXB beans for JSON supported notations description, simple address bean
8.18. JAXB beans for JSON supported notations description, contact bean
8.19. JAXB beans for JSON supported notations description, initialization
8.20. XML namespace to JSON mapping configuration for Jettison based mapped notation
8.21. JSON expression with XML namespaces mapped into JSON
8.22. JSON expression produced using badgerfish notation
8.23. ContextResolver<ObjectMapper>
8.24. Building client with Jettison JSON feature enabled.
8.25. Creating JAX-RS application with Jettison JSON feature enabled.
8.26. Simplest case of using @JSONP
8.27. JaxbBean for @JSONP example
8.28. Example of @JSONP with configured parameters.
8.29. Low level XML test - methods added to HelloWorldResource.java
8.30. Planet class
8.31. Resource class
8.32. Method for consuming Planet
8.33. Resource class - JAXBElement
8.34. Client side - JAXBElement
8.35. PlanetJAXBContextProvider
8.36. Using Provider with JAX-RS client
8.37. Add jersey-media-moxy dependency.
8.38. Register the MoxyXmlFeature class.
8.39. Configure and register an MoxyXmlFeature instance.
8.40. Building client with MultiPart feature enabled.
8.41. Creating JAX-RS application with MultiPart feature enabled.
8.42. MultiPart entity
8.43. MultiPart entity in HTTP message.
8.44. FormDataMultiPart entity
8.45. FormDataMultiPart entity in HTTP message.
8.46. Multipart - sending files.
8.47. Resource method using MultiPart as input parameter / return value.
8.48. Use of @FormDataParam annotation
9.1. Container response filter
9.2. Container request filter
9.3. Pre-matching request filter
9.4. Client request filter
9.5. GZIP writer interceptor
9.6. GZIP reader interceptor
9.7. @NameBinding example
9.8. Dynamic binding example
9.9. Priorities example
10.1. Simple async resource
10.2. Simple async method with timeout
10.3. CompletionCallback example
10.4. ChunkedOutput example
10.5. Simple client async invocation
10.6. Simple client fluent async invocation
10.7. Client async callback
10.8. Client async callback for specific entity
10.9. ChunkedInput example
11.1. URI building
11.2. Building URIs using query parameters
12.1. A standard resource class
12.2. A programmatic resource
12.3. A programmatic resource
12.4. A programmatic resource
12.5. A programmatic resource
12.6. A programmatic resource
13.1. Simple SSE resource method
13.2. Broadcasting SSE messages
13.3. Registering EventListener with EventSource
13.4. Overriding EventSource.onEvent(InboundEvent) method
14.1. Accessing SecurityContext
14.2. Injecting SecurityContext into a singleton resource
14.3. Injecting SecurityContext into singletons
14.4. Registering RolesAllowedDynamicFeature using ResourceConfig
14.5. Injecting SecurityContext into singletons
15.1. A simple WADL example - JAX-RS resource definition
15.2. A simple WADL example - WADL content
15.3. OPTIONS method returning WADL
15.4. More complex WADL example - JAX-RS resource definition
15.5. More complex WADL example - WADL content
16.1. Configuring Jersey specific properties for Bean Validation.
16.2. Using ValidationConfig to configure Validator.
16.3. Constraint annotations on input parameters
16.4. Constraint annotations on fields
16.5. Constraint annotations on class
16.6. Definition of a constraint annotation
16.7. Validator implementation.
16.8. Entity validation
16.9. Entity validation 2
16.10. Response entity validation
16.11. Validate getter on execution
16.12. Injecting UriInfo into a ConstraintValidator
16.13. Support for injecting Jersey's resources/providers via ConstraintValidatorFactory.
16.14. ValidationError to text/plain
16.15. ValidationError to text/html
16.16. ValidationError to application/xml
16.17. ValidationError to application/json
17.1. Registering MvcFeature
17.2. Registering JspMvcFeature
17.3. Setting MvcProperties.TEMPLATE_BASE_PATH value in ResourceConfig
17.4. Setting FreemarkerMvcProperties.TEMPLATE_BASE_PATH value in web.xml
17.5. Using Viewable in a resource class
17.6. Using absolute path to template in Viewable
17.7. Using @Template on a resource class
17.8. Custom TemplateProcessor
17.9. Registering custom TemplateProcessor
20.1. Jersey 1 reloader implementation
20.2. Jersey 1 reloader registration
20.3. Jersey 2 reloader implementation
20.4. Jersey 2 reloader registration