Apache CXF API

org.apache.cxf.transport.common.gzip
Class GZIPOutInterceptor

java.lang.Object
  extended by org.apache.cxf.phase.AbstractPhaseInterceptor<Message>
      extended by org.apache.cxf.transport.common.gzip.GZIPOutInterceptor
All Implemented Interfaces:
Interceptor<Message>, PhaseInterceptor<Message>

public class GZIPOutInterceptor
extends AbstractPhaseInterceptor<Message>

CXF interceptor that compresses outgoing messages using gzip and sets the HTTP Content-Encoding header appropriately. An instance of this class should be added as an out interceptor on clients that need to talk to a service that accepts gzip-encoded requests or on a service that wants to be able to return compressed responses. In server mode, the interceptor only compresses responses if the client indicated (via an Accept-Encoding header on the request) that it can understand them. To handle gzip-encoded input messages, see GZIPInInterceptor. This interceptor supports a compression threshold (default 1kB) - messages smaller than this threshold will not be compressed. To force compression of all messages, set the threshold to 0. This class was originally based on one of the CXF samples (configuration_interceptor).

Author:
Ian Roberts (i.roberts@dcs.shef.ac.uk)

Nested Class Summary
static class GZIPOutInterceptor.UseGzip
          Enum giving the possible values for whether we should gzip a particular message.
 
Field Summary
static String GZIP_ENCODING_KEY
          Key under which we store the name which should be used for the content-encoding of the outgoing message.
static String ORIGINAL_OUTPUT_STREAM_KEY
          Key under which we store the original output stream on the message, for use by the ending interceptor.
static String SOAP_JMS_CONTENTENCODING
           
static String USE_GZIP_KEY
          Key under which we store an indication of whether compression is permitted or required, for use by the ending interceptor.
 
Constructor Summary
GZIPOutInterceptor()
           
GZIPOutInterceptor(int threshold)
           
 
Method Summary
 int getThreshold()
           
 void handleMessage(Message message)
          Intercepts a message.
 void setThreshold(int threshold)
           
 
Methods inherited from class org.apache.cxf.phase.AbstractPhaseInterceptor
addAfter, addAfter, addBefore, addBefore, getAdditionalInterceptors, getAfter, getBefore, getId, getPhase, handleFault, isGET, isRequestor, setAfter, setBefore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORIGINAL_OUTPUT_STREAM_KEY

public static final String ORIGINAL_OUTPUT_STREAM_KEY
Key under which we store the original output stream on the message, for use by the ending interceptor.


USE_GZIP_KEY

public static final String USE_GZIP_KEY
Key under which we store an indication of whether compression is permitted or required, for use by the ending interceptor.


GZIP_ENCODING_KEY

public static final String GZIP_ENCODING_KEY
Key under which we store the name which should be used for the content-encoding of the outgoing message. Typically "gzip" but may be "x-gzip" if we are processing a response message and this is the name given by the client in Accept-Encoding.


SOAP_JMS_CONTENTENCODING

public static final String SOAP_JMS_CONTENTENCODING
See Also:
Constant Field Values
Constructor Detail

GZIPOutInterceptor

public GZIPOutInterceptor()

GZIPOutInterceptor

public GZIPOutInterceptor(int threshold)
Method Detail

setThreshold

public void setThreshold(int threshold)

getThreshold

public int getThreshold()

handleMessage

public void handleMessage(Message message)
                   throws Fault
Description copied from interface: Interceptor
Intercepts a message. Interceptors should NOT invoke handleMessage or handleFault on the next interceptor - the interceptor chain will take care of this.

Throws:
Fault

Apache CXF API

Apache CXF