CXF之Interceptors
来源:互联网 发布:淘宝如何增加排名 编辑:程序博客网 时间:2024/05/20 20:44
1. Interceptors and Phases(拦截器与阶段)
Interceptors是CXF内部的根本处理单元。当服务被调用时,一个InterceptorChain被创建并调用。
每一个interceptor都有机会做他们想要处理的消息。包括:读取,转化,处理头部,验证消息 ,等。
Interceptors可以用于CXF的客户端和服务端。当一个CXF客户端调用一个CXF服务端的时候,
客户端有一个传出的interceptor链,服务端有一个传入的interceptor链。当服务端发送响应给
客户端时,服务端有一个传出的interceptor链,客户端有一个传入的interceptor链。此外,在
SOAPFaults情况下,一个CXF web服务将创建单独的对外输出错误处理链,客户端将创建一个
传入的错误处理链。
InterceptorChains被划分成阶段。每个阶段可以包含许多interceptors. 在传入链中,你将有以下几个阶段:
Phase---------------------------------------------Functions
-----------------------------------------------------------------------------------------------------------------
RECEIVE------------------------------------------Transport level processing
(PRE/USER/POST)_STREAM--------------------Stream level processing/transformations
READ----------------------------------------------This is where header reading typically occurs.
(PRE/USER/POST)_PROTOCOL----------------Protocol processing, such as JAX-WS SOAP handlers
UNMARSHAL--------------------------------------Unmarshalling of the request
(PRE/USER/POST)_LOGICAL-------------------Processing of the umarshalled request
PRE_INVOKE--------------------------------------Pre invocation actions
INVOKE--------------------------------------------Invocation of the service
POST_INVOKE------------------------------------Invocation of the outgoing chain if there is one
传出链中,也有几个阶段:
Phase Functions
----------------------------------------------------------------------------------------------------------------
SETUP----------------------------------------------Any set up for the following phases
(PRE/USER/POST)_LOGICAL-------------------Processing of objects about to marshalled
PREPARE_SEND----------------------------------Opening of the connection
PRE_STREAM
PRE_PROTOCOL----------------------------------Misc protocol actions.
WRITE----------------------------------------------Writing of the protocol message, such as the SOAP Envelope.
MARSHAL-------------------------------------------Marshalling of the objects
(USER/POST)_PROTOCOL-----------------------Processing of the protocol message.
(USER/POST)_STREAM---------------------------Processing of the byte level message
SEND------------------------------------------------Final sending of message and closing of transport stream
2. InterceptorProviders
CXF包含的几个不同的组件可以提供将interceptors放到InterceptorChain中. 它们实现了InterceptorProvider接口:
添加一个interceptor到一个interceptor链,你只需要把它添加到一个InterceptorProviders:
CXF包含的一些InterceptorProviders是:
. Client
. Endpoint
. Service
. Bus
. Binding
3. 编写并配置一个Interceptor
编写一个Interceptor
写一个拦截器是相对简单的。你的interceptor需要继承AbstractPhaseInterceptor或者它的许多子类,例如AbstractSoapInterceptor.
从AbstractPhaseInterceptor继承,允许你的interceptor访问消息接口的方法 。如例:
继承自AbstractPhaseInterceptor的子类,允许你的interceptor访问比在Message接口中更多的信息。
AbstractSoapInterceptor是AbstractPhaseInterceptor的子类。继承自这个类,允许你的interceptor
访问SoapMessage类的SOAP头和版本消息。如例:
注意,你需要指定这阶段要包含进来的interceptor. 这是在拦截器的构造器上进行:
你还可以在拦截器运行前/后在同一阶段定义某些其它拦截器:
你可以添加interceptors到interceptor链中,通过编程方式 或 配置方式. ----略。
- CXF之Interceptors
- CXF之Interceptors运用实例
- OkHttp之Interceptors
- interceptors
- Adding Gzip Compression in CXF APIs and Interceptors
- Okhttp-wiki 之 Interceptors 拦截器
- Spring MVC 之 Interceptors拦截器
- springMVC之mvc:interceptors拦截器的用法
- springMVC之mvc:interceptors拦截器的用法
- springMVC之mvc:interceptors拦截器的用法
- Android OkHttp官方Wiki之Interceptors拦截器
- SpringMVC之拦截器(interceptors)的简介及用法
- springMVC之mvc:interceptors拦截器的用法
- CXF之Features
- Webservice之CXF组件
- webService之cxf
- CXF之Features
- Spring+CXF之集成
- QT Creator 2.0编译会将可执行文件生成到一个类似projectname_build-desktop的目录中,解决办法
- 中文简繁互转的三种方法
- Oracle 语法之 OVER (PARTITION BY ..) 及开窗函数
- ExtJs之Ext.data.Store
- 在IE6下z-index失效
- CXF之Interceptors
- 用javascript实现显示当前时间
- struts2 参数绑定和二次绑定
- asp.net 网站部署问题:
- sed 示例
- C代码优化案例
- 万年历
- 第五次个人赛E题 Bone Collector 01背包问题
- 修改linux系统安装界面的语言!