I'm using Jersey 1.13 with Spring. I've got a ContextResolver defined like so:
@Provider
public class ThemeSourceContextResolver implements ContextResolver<ThemeSource> {
@Context private HttpServletRequest request;
@Override
public ThemeSource getContext(Class<?> type) {
return new DefaultThemeSource(request);
}
}
<bean id="themeSourceContextResolver" scope="singleton" class="com.example.ThemeSourceContextResolver" />
Is the above valid? Specifically, is it "legal" (or does it make sense) to use the @Context private HttpServletRequest request
in a ContextResolver? Since the ContextResolver is a singleton, does Jersey/JAX-RS do some threadlocal proxy magic or something to allow it to have access to the HttpServletRequest of every request?