开发者

Issue with Spring Method interceptor

开发者 https://www.devze.com 2023-03-25 03:46 出处:网络
I\'m having an issue with using Spring interceptor. I\'ve a CXF service endpoint method which I\'m trying a wrap with an interceptor to do some initialization. For some reason, the interceptor is not

I'm having an issue with using Spring interceptor. I've a CXF service endpoint method which I'm trying a wrap with an interceptor to do some initialization. For some reason, the interceptor is not being invoked. Here's my spring entry:

<jaxrs:server id="acadConnectServer" address="/rest/acadconnect3">
    <jaxrs:serviceBeans>
        <ref bean="acadConnectResource" />
    </jaxrs:serviceBeans>
</jaxrs:server>
<bean id="acadConnectResource"
    class="com.test.connectchannel.service.AcadConnectChannelResource" />
<bean id="connectResource" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="target" ref="acadConnectResource" />
    <property name="interceptorNames">
        <list>
            <value>methodPointCut</value>
        </list>
    </property>
</bean>
<bean id="methodPointCut"
    class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
    <property name="advice">
        <ref local="methodInterceptor" />
    </property>
    <property name="mappedNames">
        <list>
            <value>search</value>
            <value>searchJSONP</value>
        </list>
    </property>
</bean>
开发者_如何学运维<bean id="methodInterceptor"
    class="com.test.connectchannel.util.ConnectChannelInterceptor">
</bean>

As you can see, I've a CXF endpoint class AcadConnectChannelResource which has couple of methods search and searchJSONp. I've created the Named Method Cut interceptor to intercept these two method calls and so some initialization using the custom intercetor class.But, everytime the methods are invoked, the interceptor is not being called.

Not sure what I'm missing here, any pointer will be appreciated.

-Thanks


I might be entirely wrong, but don't you want

<ref bean="connectResource" />

instead of

<ref bean="acadConnectResource" />

in your <jaxrs:server>? You're proxying the resource, but using the raw resource instead of the proxy.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号