Spring 方法拦截器的问题

发布于 2024-11-27 18:03:08 字数 1511 浏览 5 评论 0原文

我在使用 Spring 拦截器时遇到问题。我有一个 CXF 服务端点方法,我正在尝试用拦截器进行包装来进行一些初始化。由于某种原因,拦截器没有被调用。这是我的 spring 条目:

<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>

如您所见,我有一个 CXF 端点类 AcadConnectChannelResource,它有几个方法 search 和 searchJSONp。我创建了命名方法剪切拦截器来拦截这两个方法调用,因此使用自定义拦截器类进行一些初始化。但是,每次调用方法时,拦截器都不会被调用。

不确定我在这里缺少什么,任何指针将不胜感激。

-谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∝单色的世界 2024-12-04 18:03:08

我可能完全错了,但是您不想

<ref bean="connectResource" />

<ref bean="acadConnectResource" />

您的 中使用它吗?您正在代理资源,但使用原始资源而不是代理。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文