Hi,

I don't want to customize anything. I just want to find the method name and arguments and log them in a generic manner so I don't have to put a log statement it in every service call.

Looks like that JAXRSBeanValidationInInterceptor and its base class BeanValidationInInterceptor are gonna do the trick. I can't check right it now but it's the first thing I will check Monday morning.

Thanks as always for the prompt answer.

     Vassilis


On 2014-10-17 12:43, Sergey Beryozkin wrote:
Hi

Why do you have to customize these interceptors ?

Have a look at org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInInterceptor

it shows how all this info can be obtained...

Cheers, Sergey
On 17/10/14 15:35, Vassilis Virvilis wrote:
Hi,

I managed to install my own JAXRSInInterceptor and JAXRSOutInterceptor.

What I would like is to log the final method name and parameter values
for logging purposes. I have done something similar for SOAP in the past
but the crucial BindingOperationInfo is null in case of rest.

Any ideas?

     private String getMethod(Message message) {
         final BindingOperationInfo bop =
message.getExchange().getBindingOperationInfo();
         if (bop != null) {
             final MethodDispatcher md = (MethodDispatcher) message
                     .getExchange().get(Service.class)
                     .get(MethodDispatcher.class.getName());

             Object parameters = message.getContent(List.class);
             if (parameters == null) {
                 parameters = message.getContent(Object.class);
             }

return String.format("%s(%s)", md.getMethod(bop).getName(),
                 StringUtils.preetyPrintObject(new StringBuilder(),
parameters,
                     -1));
         }
         final Method method = (Method) message
                 .get("org.apache.cxf.resource.method");
         if (method != null) {
             return method.getName();
         }
         return "unknown";
     }


     Vassilis Virvilis

Reply via email to