@ChannelPipelineCoverage(value="one") public class ChunkedWriteHandler extends Object implements ChannelUpstreamHandler, ChannelDownstreamHandler
ChannelHandler
that adds support for writing a large data stream
asynchronously neither spending a lot of memory nor getting
OutOfMemoryError
. Large data streaming such as file
transfer requires complicated state management in a ChannelHandler
implementation. ChunkedWriteHandler
manages such complicated states
so that you can send a large data stream without difficulties.
To use ChunkedWriteHandler
in your application, you have to insert
a new ChunkedWriteHandler
instance:
ChannelPipeline p = ...; p.addLast("streamer", new ChunkedWriteHandler()); p.addLast("handler", new MyHandler());Once inserted, you can write a
ChunkedInput
so that the
ChunkedWriteHandler
can pick it up and fetch the content of the
stream chunk by chunk and write the fetched chunk downstream:
Channel ch = ...; ch.write(new ChunkedFile(new File("video.mkv"));
Constructor and Description |
---|
ChunkedWriteHandler()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
handleDownstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified downstream event.
|
void |
handleUpstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified upstream event.
|
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception
ChannelDownstreamHandler
handleDownstream
in interface ChannelDownstreamHandler
ctx
- the context object for this handlere
- the downstream event to process or interceptException
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception
ChannelUpstreamHandler
handleUpstream
in interface ChannelUpstreamHandler
ctx
- the context object for this handlere
- the upstream event to process or interceptException
Copyright © 2008-2013 JBoss, by Red Hat. All Rights Reserved.