I am not an expert on the topic but to me it seems as if the MessageBodyReaderContext
interface does not really know if it is on the server or the client side, so it cannot expose the request or its parameters / path parts etc.
So as far as I know this is not possible.
If your code knows that it lives on the server side of the rest
communication, maybe you can use a servlet filter to store the request
in a ThreadLocal and then access it from there while the request is
handled, somewhat similar to RequestContextFilter
/ RequestContextHolder
from the spring framework? (Then the request object does not know anything about the annotations of your service, but instead one has to extract the information manually from the request. This means to have the same information in two places, so there has to be a better solution ...)
Edit: after looking at some examples I get the vague feeling that if you want to read the input stream to create an object and add path parameters to it, MessageBodyReaderInterceptor
is simply not the way to go. Instead set up a MessageBodyReader
which constructs the object from the request body data, and this then will be passed into the public String setData(@PathParam("id") Long is, MyObject payload)
, assuming that this method is annotated with a @Consumes
which matches the @ConsumeMime
annotation for the MessageBodyReader
. There you might be able in the setData
to set the missing id on the object read from the request body. Some examples related to this seem to be here: How to get full REST request body using Jersey? (but for Jersey, not jBoss :-/)
However I am not sure if that works for you, and I also feel I completely overestimated my ability to answer this question appropriately, so I hope someone more knowledgeable comes in with a better solution.