public abstract class AbstractFileChunkedStrategy<T> extends java.lang.Object implements FileChunkedStrategy<T>
FileChunkedStrategy. Only the
FileChunkedStrategy.chunkFile(FileChannel) method needs to be implemented, but child classes
can also override afterWrite(NettyContext) to add custom cleanup.
The pipeline preparation and cleanup involves adding and removing the
NettyPipeline.ChunkedWriter handler if it was not already present. It will be
added before NettyPipeline.ReactiveBridge or last, if the bridge handler is not
present.| Constructor and Description |
|---|
AbstractFileChunkedStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterWrite(NettyContext context)
Additional cleanup to perform at the end of
cleanupPipeline(NettyContext). |
void |
cleanupPipeline(NettyContext context)
Once the file has been written, allows to clean the pipeline
(see
FileChunkedStrategy.preparePipeline(NettyContext)) and do other operations. |
void |
preparePipeline(NettyContext context)
Allow for preparing the pipeline (eg.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitchunkFilepublic final void preparePipeline(NettyContext context)
NettyContext is provided and can be used to get the
channel() then pipeline().
This adds a ChunkedWriter to the pipeline to extract chunks from the
ChunkedInput that the strategy produces. This step
is skipped if the handler is already present, and the placement of the handler
depends on the presence of the ReactiveBridge handler (see NettyPipeline).
preparePipeline in interface FileChunkedStrategy<T>context - the context from which to obtain the channel and pipelinepublic final void cleanupPipeline(NettyContext context)
FileChunkedStrategy.preparePipeline(NettyContext)) and do other operations.
This removes the ChunkedWriter handler if it was added by this strategy. It then
calls the afterWrite(NettyContext) method
cleanupPipeline in interface FileChunkedStrategy<T>context - the context from which to obtain the channel and pipelineprotected void afterWrite(NettyContext context)
cleanupPipeline(NettyContext).context - the NettyContext