We’re currently using Jersey OAuth filter. The requirement is that we need to push ContainerRequest and ContainerResponse datagrams (and any exceptions if applicable) together to a third-party data store which provides a push API which works asynchronously. I’ve read about ContainerRequestFilters and ContainerResponseFilters interfaces and LoggingFilter (which uses a Logger to write data to). Instead of making two push calls to send request and response datagram separately, I would like to combine that into a single call. I see that ContainerResponseFilters takes both ContainerRequest and ContainerResponse, so is it feasible and good to implement that interface to push this data together. Will that work even when OAuth filter throws some other exception? Are there any other better alternatives?
Thanks in advance.
Answering for the sake of others,
AFAIK, there is no straightforward way to have both the request and response data together as
ContainerRequestFiltersimplementation deals with theContainerRequestand reads the input stream andContainerResponseFiltersimplementation deals with theContainerResponseobject. One can still access the request headers in thefiltermethod ofContainerResponseFiltersimplementation, but not the entity. I had to use the properties map (which seems to be mutable) as a temporary map to put request entity and retrieve that in the response filter. It looks like a dirty hack, but I didn’t find any other way.