Interceptors are a low-level pieces of code that process messages as they are passed between the message channel and service's implementation. They have access to the raw message data and can be used to process SOAP action entries, process security tokens, or correlate messages. Interceptors are called in a chain and you can configure what interceptors are used at a number of points along the chain.
A FUSE Services Framework binding component endpoint's interceptor chain has four points at which you can insert an interceptor:
On consumer endpoints the in interceptors process messages when they are received from the external endpoint.
On provider endpoints the in interceptors process messages when they are received from the NMR.
The in fault interceptors process fault messages that are generated before the service implementation gets called.
On consumer endpoints the out interceptors process messages as they pass from the service implementation to the external endpoint.
On provider endpoints the out interceptors process messages as they pass from the service implementation to the NMR.
The out fault interceptors process fault messages that are generated by the service implementation or by an out interceptor.
An endpoint's interceptor chain is configured using children of its consumer element or provider element. Table 13.1 lists the elements used to configure an endpoint's interceptor chain.
Table 13.1. Elements Used to Configure an Endpoint's Interceptor Chain
Example 13.1 shows a consumer endpoint configured to use the FUSE Services Framework logging interceptors.
Example 13.1. Configuring an Interceptor Chain
<cxfbc:consumer ...>
...
<cxfbc:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
</cxfbc:inInterceptors>
<cxfbc:outInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
</cxfbc:outInterceptors>
<cxfbc:inFaultInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
</cxfbc:inFaultInterceptors>
<cxfbc:outFaultInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
</cxfbc:outFaultInterceptors>
</cxfbc:consumer>You can implement a custom interceptor by extending the org.apache.cxf.phase.AbstractPhaseInterceptor class or one of its sub-classes. Extending AbstractPhaseInterceptor provides you with access to the generic message handling APIs used by FUSE Services Framework. Extending one of the sub-classes provides you with more specific APIs. For example, extending the AbstractSoapInterceptor class allows your interceptor to work directly with the SOAP APIs.
For more information about writing FUSE Services Framework interceptors see the Apache CXF documentation.