Parameters, fields, and bean properties that are initialized using data from the HTTP request message have their values injected into them by the runtime. The specific data that is injected is specified by a set of annotations described in Using JAX-RS APIs.
The JAX-RS specification places a few restrictions on when the data is injected. It also places a few restrictions on the types of objects into which request data can be injected.
Request data is injected into objects when they are instantiated due to a request. This means that only
objects that directly correspond to a resource can use the injection annotations. As discussed in
Creating Resources, these objects will either be a root resource decorated with the
@Path
annotation or an object returned from a sub-resource locator method.
The specific set of data types that data can be injected into depends on the annotation used to specify the source of the injected data. However, all of the injection annotations support at least the following set of data types:
primitives such as int, char, or long
Objects that have a constructor that accepts a single String argument
Objects that have a static
valueOf()
method that accepts a single String argumentList<
,T
>Set<
, orT
>SortedSet<
objects whereT
>T
satisfies the other conditions in the list
![]() | Tip |
---|---|
Where injection annotations have different requirements for supported data types, the differences will be highlighted in the discussion of the annotation. |