关键字:cxf教程,CXF,Interceptors,拦截器,编写,配置
1. Interceptors and Phases(拦截器与阶段)
Interceptors是CXF内部的根本处理单元。当服务被调用时,一个InterceptorChain被创建并调用。每一个interceptor都有机会做他们想要处理的消息。包括:读取,转化,美国服务器,处理头部,验证消息 ,香港服务器租用,等。
Interceptors可以用于CXF的客户端和服务端。当一个CXF客户端调用一个CXF服务端的时候,客户端有一个传出的interceptor链,服务端有一个传入的interceptor链。当服务端发送响应给客户端时,服务端有一个传出的interceptor链,客户端有一个传入的interceptor链。此外,在SOAPFaults情况下,一个CXF web服务将创建单独的对外输出错误处理链,客户端将创建一个传入的错误处理链。
编辑推荐:
1. cxf教程:java CXF之Features的编写与配置
2. cxf教程:java CXF之Features的运行实例
3. cxf教程:java CXF之Interceptors拦截器的编写与配置
4. cxf教程:java CXF之Interceptors运用实例
文章来源:爱上123 原文地址:
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接口:
public interface InterceptorProvider {List<Interceptor> getInInterceptors();List<Interceptor> getOutInterceptors();List<Interceptor> getOutFaultInterceptors();List<Interceptor> getInFaultInterceptors();} ,香港服务器只有流过血的手指才能弹出世间的绝唱。