Top Inners Fields Constructors Methods
org.eclipse.jetty.server.handler.gzip

public Class GzipResponseAndCallback

extends Wrapper
implements Callback, Invocable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.thread.Invocable, org.eclipse.jetty.util.Callback
Imports
java.nio.ByteBuffer, .ByteOrder, java.nio.channels.WritePendingException, java.util.concurrent.atomic.AtomicReference, java.util.zip.CRC32, .Deflater, org.eclipse.jetty.http.HttpField, .HttpFields, .HttpHeader, .HttpStatus, org.eclipse.jetty.io.RetainableByteBuffer, org.eclipse.jetty.server.Request, .Response, org.eclipse.jetty.util.BufferUtil, .Callback, .IteratingNestedCallback, org.eclipse.jetty.util.compression.DeflaterPool, org.eclipse.jetty.util.thread.Invocable, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static enum

Field Summary

Modifier and TypeField and Description
private RetainableByteBuffer
private final int
private final Callback
private final CRC32
private CompressionPool<Deflater>.Entry
private final GzipFactory
private boolean
private final AtomicReference<GzipResponseAndCallback.GZState>
private final boolean
private static final byte[]
private static final int
private static final Logger
private static final byte

Constructor Summary

AccessConstructor and Description
public
GzipResponseAndCallback(GzipHandler handler, Request request, Response response, Callback callback)

Method Summary

Modifier and TypeMethod and Description
private void
addTrailer(ByteBuffer outputBuffer)

protected void
commit(boolean last, Callback callback, ByteBuffer content)

private String
public void
failed(Throwable
the reason for the operation failure
x
)

Overrides default org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

public Invocable.InvocationType
private void
gzip(boolean complete, final Callback callback, ByteBuffer content)

public void
public void
succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

public void
write(boolean
whether the ByteBuffer is the last to write
last
,
ByteBuffer
the ByteBuffer to write
content
,
Callback
the callback to notify when the write operation is complete
callback
)

Overrides org.eclipse.jetty.server.Response.Wrapper.write.

Implements org.eclipse.jetty.server.Response.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

Inherited from org.eclipse.jetty.server.Response.Wrapper:
getHeadersgetRequestgetStatusgetTrailersSuppliergetWrappedhasLastWriteisCommittedisCompletedSuccessfullyresetsetStatussetTrailersSupplierwriteInterim

Field Detail

_bufferback to summary
private RetainableByteBuffer _buffer
_bufferSizeback to summary
private final int _bufferSize
_callbackback to summary
private final Callback _callback
_crcback to summary
private final CRC32 _crc
_deflaterEntryback to summary
private CompressionPool<Deflater>.Entry _deflaterEntry
_factoryback to summary
private final GzipFactory _factory
_lastback to summary
private boolean _last
_stateback to summary
private final AtomicReference<GzipResponseAndCallback.GZState> _state
_syncFlushback to summary
private final boolean _syncFlush
GZIP_HEADERback to summary
private static final byte[] GZIP_HEADER
GZIP_TRAILER_SIZEback to summary
private static final int GZIP_TRAILER_SIZE
LOGback to summary
private static final Logger LOG
OS_UNKNOWNback to summary
private static final byte OS_UNKNOWN

Constructor Detail

GzipResponseAndCallbackback to summary
public GzipResponseAndCallback(GzipHandler handler, Request request, Response response, Callback callback)

Method Detail

addTrailerback to summary
private void addTrailer(ByteBuffer outputBuffer)
commitback to summary
protected void commit(boolean last, Callback callback, ByteBuffer content)
etagGzipback to summary
private String etagGzip(String etag)
failedback to summary
public void failed(Throwable x)

Overrides default org.eclipse.jetty.util.Callback.failed.

Doc from org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

Parameters
x:Throwable

the reason for the operation failure

Annotations
@Override
getInvocationTypeback to summary
public Invocable.InvocationType getInvocationType()

Overrides default org.eclipse.jetty.util.thread.Invocable.getInvocationType.

Returns:Invocable.InvocationType

Doc from org.eclipse.jetty.util.thread.Invocable.getInvocationType.

The InvocationType of this object

Annotations
@Override
gzipback to summary
private void gzip(boolean complete, final Callback callback, ByteBuffer content)
noCompressionback to summary
public void noCompression()
succeededback to summary
public void succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Doc from org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

Annotations
@Override
writeback to summary
public void write(boolean last, ByteBuffer content, Callback callback)

Overrides org.eclipse.jetty.server.Response.Wrapper.write.

Implements org.eclipse.jetty.server.Response.write.

Doc from org.eclipse.jetty.server.Response.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Callback and a call to this method.

The invocation of the passed Callback is serialized with previous calls of this method, so that it is not invoked until any invocation of the callback of a previous call to this method has returned.

Thus a Callback should not block waiting for a callback of a future call to this method.

Parameters
last:boolean

whether the ByteBuffer is the last to write

content:ByteBuffer

the ByteBuffer to write

callback:Callback

the callback to notify when the write operation is complete

Annotations
@Override
org.eclipse.jetty.server.handler.gzip back to summary

private Class GzipResponseAndCallback.GzipBufferCB

extends IteratingNestedCallback
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
private final boolean

Constructor Summary

AccessConstructor and Description
public
GzipBufferCB(boolean complete, Callback callback, ByteBuffer content)

Method Summary

Modifier and TypeMethod and Description
private void
private IteratingCallback.Action
compressing(Deflater deflater, ByteBuffer outputBuffer)

This method is called directly from process() to perform the compressing of the content this GzipBufferCB represents.

private IteratingCallback.Action
finishing(Deflater deflater, ByteBuffer outputBuffer)

This method is called by compressing(Deflater, ByteBuffer), once the last chunk is compressed; or directly from process() if an earlier call to this method was unable to complete.

private int
protected void
onCompleteFailure(Throwable
the throwable to indicate cause of failure
x
)

Overrides org.eclipse.jetty.util.IteratingNestedCallback.onCompleteFailure.

Invoked when the overall task has completed with a failure.
protected IteratingCallback.Action
process()

Implements abstract org.eclipse.jetty.util.IteratingCallback.process.

Method called by iterate() to process the asynchronous sub-task.
public String
toString()

Overrides org.eclipse.jetty.util.IteratingNestedCallback.toString.

Returns a string representation of the object.
private void
write(boolean last, ByteBuffer outputBuffer)

Inherited from org.eclipse.jetty.util.IteratingNestedCallback:
getInvocationTypeonCompleteSuccess

Field Detail

_contentback to summary
private final ByteBuffer _content
_lastback to summary
private final boolean _last

Constructor Detail

GzipBufferCBback to summary
public GzipBufferCB(boolean complete, Callback callback, ByteBuffer content)

Method Detail

cleanupback to summary
private void cleanup()
compressingback to summary
private IteratingCallback.Action compressing(Deflater deflater, ByteBuffer outputBuffer)

This method is called directly from process() to perform the compressing of the content this GzipBufferCB represents.

finishingback to summary
private IteratingCallback.Action finishing(Deflater deflater, ByteBuffer outputBuffer)

This method is called by compressing(Deflater, ByteBuffer), once the last chunk is compressed; or directly from process() if an earlier call to this method was unable to complete.

getFlushModeback to summary
private int getFlushMode()
onCompleteFailureback to summary
protected void onCompleteFailure(Throwable x)

Overrides org.eclipse.jetty.util.IteratingNestedCallback.onCompleteFailure.

Doc from org.eclipse.jetty.util.IteratingCallback.onCompleteFailure.

Invoked when the overall task has completed with a failure.

Parameters
x:Throwable

the throwable to indicate cause of failure

Annotations
@Override
processback to summary
protected IteratingCallback.Action process() throws Exception

Implements abstract org.eclipse.jetty.util.IteratingCallback.process.

Doc from org.eclipse.jetty.util.IteratingCallback.process.

Method called by iterate() to process the asynchronous sub-task.

Implementations must initiate the asynchronous execution of the sub-task (if any) and return an appropriate action:

  • Action#IDLE when no sub tasks are available for execution but the overall job is not completed yet
  • Action#SCHEDULED when the sub task asynchronous execution has been started
  • Action#SUCCEEDED when the overall job is completed
Returns:IteratingCallback.Action

the appropriate Action

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.eclipse.jetty.util.IteratingNestedCallback.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
writeback to summary
private void write(boolean last, ByteBuffer outputBuffer)
org.eclipse.jetty.server.handler.gzip back to summary

private final Enum GzipResponseAndCallback.GZState

extends Enum<GzipResponseAndCallback.GZState>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final GzipResponseAndCallback.GZState
public static final GzipResponseAndCallback.GZState
public static final GzipResponseAndCallback.GZState
public static final GzipResponseAndCallback.GZState
public static final GzipResponseAndCallback.GZState
public static final GzipResponseAndCallback.GZState

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static GzipResponseAndCallback.GZState
public static GzipResponseAndCallback.GZState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

COMMITTINGback to summary
public static final GzipResponseAndCallback.GZState COMMITTING
COMPRESSINGback to summary
public static final GzipResponseAndCallback.GZState COMPRESSING
FINISHEDback to summary
public static final GzipResponseAndCallback.GZState FINISHED
FINISHINGback to summary
public static final GzipResponseAndCallback.GZState FINISHING
MIGHT_COMPRESSback to summary
public static final GzipResponseAndCallback.GZState MIGHT_COMPRESS
NOT_COMPRESSINGback to summary
public static final GzipResponseAndCallback.GZState NOT_COMPRESSING

Constructor Detail

GZStateback to summary
private GZState()

Method Detail

valueOfback to summary
public static GzipResponseAndCallback.GZState valueOf(String name)
valuesback to summary
public static GzipResponseAndCallback.GZState[] values()