Chapter 5. JAX-RS Injection
A lot of JAX-RS is pulling information from an HTTP request and injecting it into a Java
method. You may be interested in a fragment of the incoming URI. You might be interested
in a URI query string value. The client might be sending critical HTTP headers or cookie
values that your service needs to process the request. JAX-RS lets you grab this information
à la carte, as you need it, through a set of injection annotations and APIs.
There are a lot of different things JAX-RS annotations can inject. Here is a list of those
provided by the specification:
This annotation allows you to extract values from URI template parameters.
This annotation allows you to extract values from URI matrix parameters.
This annotation allows you to extract values from URI query parameters.
This annotation allows you to extract values from posted form data.
This annotation allows you to extract values from HTTP request headers.
This annotation allows you to extract values from HTTP cookies set by the client.
This class is the all-purpose injection annotation. It allows you to inject various helper
and informational objects that are provided by the JAX-RS API.
Usually, these annotations are used on the parameters of a JAX-RS resource method. When
the JAX-RS provider receives an HTTP request, it finds a Java method that will service this
request. If the Java method has parameters that are annotated with any of these injection an-
notations, it will extract information from the HTTP request and pass it as a parameter when
it invokes the method.