Skip to content

Determine target service/method from CXF Interceptor

I’d like to write an interceptor for the Apache CXF JAX-RS implementation that inspects the target service/method for a particular annotation and does some special processing for that annotation.

I can’t seem to find anything in the interceptor documentation that describes how to do this. Does anyone have any ideas?




Ah. I didn’t specify that I was using the JAX-RS part of CXF; not sure if that impacts Daniel Kulp’s answer but his solution didn’t actually work for me. I believe it is because CXF does things differently when handling JAX-RS.

I came across the source for CXF’s [JAXRSInInterceptor][1] and I saw in that code that this interceptor is putting the method info into the Exchange object like so:

message.getExchange().put(OperationResourceInfo.class, ori);

…during the UNMARSHAL phase, which according to the CXF interceptor docs happens before the *_LOGICAL phase. So by writing an Interceptor that handles the USER_LOGICAL phase I can do:


…to get access in there to the Method and Class<?> of the Service handling the call!

1 People found this is helpful