真的可以将对Web服务的引用连接到拦截器中吗? [英] Can really I wire a reference to the web service into an interceptor?

查看:69
本文介绍了真的可以将对Web服务的引用连接到拦截器中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CXF和Web服务的新手。

I'm new to both CXF and Web Services.

因此CXF根据文档为每个请求创建一个新的拦截器堆栈。我想获取SOAP,有效负载和所有信息,并将其用于持久化到异常表。我已经基于LoggingInterceptor编写了一个拦截器,该拦截器可能会正常工作,并且我的IDE表示连接良好,我的关注点是线程化和/或创建Web服务时。

So CXF creates a new interceptor stack for each request according to docs. I want to snag the SOAP, payload and all, and have it available for persistence to an exception table. I've written an interceptor based on LoggingInterceptor that will likely work fine and my IDE says the wiring is fine, my concern is threading and / or when the Web Service is created.

出于某种原因,我有一个令人doubt惑的怀疑,认为这将起作用并且与线程有关。我只是无法用手指指着它。

For some reason I have this nagging doubt that this is going to work and that it has to do with threading. I just can't put my finger on it though.

推荐答案

CXF会为每个请求创建一个新的 PhaseInterceptorChain对象,但不会根据请求创建拦截器本身。因此,如果您确保handleMessage(和handleFault)方法正确地是线程安全的,则将单例用作拦截器是完全可以的。

CXF creates a new "PhaseInterceptorChain" object per request, but the interceptors themselves are not created per request. Thus, using a singleton for the interceptor is perfectly OK providing you make sure the handleMessage (and handleFault) methods are properly thread safe.

这篇关于真的可以将对Web服务的引用连接到拦截器中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆