Using @Context in JAX-RS

Written on May 7, 2015

The @Context annotation gives, to a JAX-RS implementation, the ability to inject contextual information (e.g. Configuration, Security Context, etc. ) in a JAX-RS end-point. This capability is available since the early day of the specification, since JAX-RS 1.0. There are many scenarios where this feature is useful (e.g. access one of the HTTP header parameter of the consuming client, etc.).

To get more information, you can check the JAX-RS Specification (@Context is described in Chapter 9 & 10) or alternatively, you can read this ‘Using @Context in JAX-RS’ piece written by Abhishek Gupta (see first instalment here).

Originaly posted on The Aquarium blog.