[jax-rs-spec users] custom _at_Context injection

From: Bill Burke <>
Date: Wed, 17 Dec 2014 09:15:36 -0500

Currently there is no way to pass information from a filter to a
resource. It would be cool if there was a method on
ContainerRequestContext (or something) that could register a value that
could be injected via @Context. For example:

containerRequestContext.pushContext(IDToken.class, token);

public class Resource {
     @Context IDToken token;

I wish I had suggested this in JAX-RS 2.0 :( as I use this pattern with
a proprietary API all the time. I can't believe I forgot to suggest it!

Also, it might be interesting to allow injection of the
ContainerRequestContext instance into resource classes as well:

public class Resource {

    @Context ContainerRequestContext context;


Not sure about this one. The reasoning would be to add/extract property
metadata from the context. Haven't had a need for this one yet.

Bill Burke
JBoss, a division of Red Hat