tags:

views:

102

answers:

2

Hi,

I want to convert some of our internal API into a spring bean spring interceptor that we can use in other projects. This API needs some instantiation and other logic which I want to encapsulate in this bean so that we can just put the bean into our app context with necessary propoerties alone, and this will then apply the logic.

I remember having read an article on this somewhere in the past - but cant find it now. Any pointers to something similar will be helpful

EDIT: Sorry, I meant a spring interceptor, not a bean - my bad - please see my edit. I want to apply this interceptor to another bean dealing in XML messages.

EDIT 2: ANSWER FOUND found it!

I found the answer to this - we were looking to insert the interceptor at the point where we were calling our webservice. So I looked at the interceptor package in spring-ws and found this end point interceptor interface. We will now implement this interceptor and put our processing logic in the appropriate handle*() method.

http://static.springsource.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/server/EndpointInterceptor.html

A: 

As with everything in spring, there are a million ways to implement AOP. Check out the spring doco on AOP, the section on declaring aspects in xml may be the most convenient in your situation. You can configure an aspect

<aop:aspect id="myAspect" ref="existingBean">
    <aop:before pointcut="execution(* com.package.to.intercept.*(..))" method="existingMethod"/>
</aop:aspect>

Or you could create new classes that use the AspectJ annotations and use those aspects to farm off to your actual work to your existing beans.

krock
Hi, we found a way to write an end point interceptor on our WS, will try this as well.
Hari
A: 
Hari
That refers to Spring-Flex (the BlazeDS integration), not Spring in general.
skaffman