While upgrading a Jersey1 + Weld 1.1 to Jersey2 + Weld 2.2 I faced one
interesting difference:
With Jersey1 it was possible to inject @Context fields into pure CDI
components like interceptors.
e.g.
@Auth
@Interceptor
public class AuthInterceptor {
@Context
private UriInfo uriInfo;
@Context
private HttpServletRequest request;
@Context
private HttpHeaders headers;
@AroundInvoke
public Object process(final InvocationContext ctx) throws Exception {
…
}
}
With Jersey2 it looks like the @Context injection works fine for the
resource classes, but not for interceptors.
I have two questions here:
1. Is there an easy way to enable @Context injection on CDI interceptors
with Jersey 2?
2. If not, is there a programmatic way of getting the "current"
(thread-local?) http headers, request, etc?
Thanks,
Pavel