In Jersey 1 you can create a container response filter and get access to the Response:
public ContainerResponse filter(ContainerRequest request, ContainerResponse response)
{
Response r = response.getResponse();
// Now I have access to Reponse.getMetadata(), etc.
}
But in Jersey 2, the ContainerResponseFilter only gives me the response context:
public void filter(ContainerRequestContext requestContext,
ContainerResponseContext responseContext) throws IOException
{
// responseContext gives me the entity, but I want the JAX-RS Response object that my resources created
}
The implementation of ContainerResponseContext is ContainerResponse, which requires a JAX-RS Response object to build. So why can't I get access to it from within the filter? Am I missing something?
The problem I have is that my resources all build Response objects and attach meta data to them, and I'd like a response filter that can examine this meta data. Without access to the raw Response, this doesn't seem possible.