[
https://issues.apache.org/jira/browse/CXF-2709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845142#action_12845142
]
Sergey Beryozkin commented on CXF-2709:
---------------------------------------
Hi Stephen
First, extending JAXRSInvoker would give you a chance to intercept sub resource
invocations too,
just extend
public Object invoke(Exchange exchange, Object request, Object resourceObject) {
}
You will get this method invoked for the root resource and then for every
subsequent sub resource invocation (provided you delegate to the super class
after validating/etc)
please see
http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
for more info.
> Now I wouldn't implement it that way, I would probably create my own
> interceptor interface and execute those in my own custom implementation of
> (JAXRS|JAXWS)Invoker.
sounds reasonable...
> When working with interfaces, I can be reasonably assured that updates wont
> break my code.
I see your concern. I really do not plan on changing the signature of
invoke(Exchange exchange, Object request, Object resourceObject)
That said I was planning to add so called invocation RequestHandlers, they will
execute before every invocation (on root and all the subresources) as opposed
to 'regular' RequestHandlers which execute only once before a root resource is
invoked.
Introducing per-method specific filters seems interesting; I agree with Andreas
you can do what you need using existing api but I'll think what else can be
done, may take a bit of time.
Sergey
cheers, Sergey
> Provide Method Invocation Interceptor
> -------------------------------------
>
> Key: CXF-2709
> URL: https://issues.apache.org/jira/browse/CXF-2709
> Project: CXF
> Issue Type: New Feature
> Components: Configuration, Core, JAX-RS, JAX-WS Runtime
> Affects Versions: 2.2.5
> Environment: JAX-RS, JAX-WS
> Reporter: Stephen Todd
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.