Chapter 2. The Interceptor APIs

All of the interceptors in FUSE Services Framework implement the base Interceptor interface shown in Example 2.1, “The Interceptor Interface”.


The Interceptor interface defines the two methods that a developer needs to implement for a custom interceptor:

handleMessage()

The handleMessage() method does most of the work in an interceptor. It is called on each interceptor in a message chain and passed in the contents of the message being processed. Developers implement the message processing logic of the interceptor in this method. For detailed information about implementing the handleMessage() method see Processing Messages.

handleFault()

The handleFault() method is called on an interceptor when normal message processing has been interrupted. The runtime calls the handleFault() method of each invoked interceptor in reverse order as it unwinds an interceptor chain. For detailed information about implementing the handleFault() method see Fault Handling.

Most interceptors do not directly implement the Interceptor interface. Instead they implement the PhaseInterceptor interface shown in Example 2.2, “The PhaseInterceptor Interface”.


The PhaseInterceptor interface adds four methods that allow an interceptor the participate in interceptor chains. Normally developers do not need to worry about implementing the additional methods provided by the PhaseInterceptor interface. Developers will, however, occasionally make use of them to position their interceptors in an interceptor chain.

Instead of directly implementing the PhaseInterceptor interface, developers should extend the AbstractPhaseInterceptor class. This abstract class provides implementations for the phase management methods of the PhaseInterceptor interface. The AbstractPhaseInterceptor class also provides a default implementation of the handleFault() method.

Developers need to provide an implementation of the handleMessage() method. They can also provide a different implementation for the handleFault() method. The developer provided implementations can manipulate the message data using the methods provided by the generic org.apache.cxf.message.Message interface.

For applications that work with SOAP messages FUSE Services Framework provides an AbstractSoapInterceptor class. Extending this class provides the handleMessage() method and the handleFault() method with access to the message data as an org.apache.cxf.binding.soap.SoapMessage object. SoapMessage objects have methods for retrieving the SOAP headers, the SOAP envelope, and other SOAP metadata from the message.