Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-2709

Provide Method Invocation Interceptor




      It would be helpful if there was some kind of MethodInvocationInterceptor (or alternatively with In/Out variants) that could be applied against Invokers before they do the actual method call for jax-rs and jax-ws. I'm thinking the place that the interceptor would be called is in AbstractInvoker.performInvocation() around m.invoke().

      What this provides for is the ability to perform some action or filtering based on information from the java.lang.Method, parameter and return values before or after the invocation is actually made.

      Two cases that I am looking at are to be able to check for annotations on a method and do some processing for security, transaction management, and/or validation. Currently, the only way to be able to perform logic on custom annotations is to create proxies around singleton beans or something like aspectj. By allowing for these kind of interceptors, this would no longer be necessary.

      These interceptors make it simple to do things such as check for spring-security @Pre/PostAuthorize annotations and apply security constraints. Likewise, I'm also wanting to implement JSR-303 validation checking against method parameters like is done for spring @Controller classes. This would keep cxf's jaxrs implementation on par with spring's rest framework. Adding @Transactional logic would also be possible through this.

      In jax-rs, not having this creates difficulty providing this logic since using singletons imposes the requirement that the resources be stateless. The java changes would be simple, though it would also need some work done in spring configuration code as well.




            sergey_beryozkin Sergey Beryozkin
            blurryrunner Stephen Todd
            0 Vote for this issue
            1 Start watching this issue