public class FeedableBodyGenerator extends Object implements BodyGenerator
BodyGenerator
that allows data to be fed to the
connection in blocking or non-blocking fashion via the use of a FeedableBodyGenerator.Feeder
.
This class provides two FeedableBodyGenerator.Feeder
implementations for rapid prototyping.
First is the FeedableBodyGenerator.SimpleFeeder
which is simply a listener that asynchronous
data transferring has been initiated. The second is the FeedableBodyGenerator.NonBlockingFeeder
which allows reading and feeding data in a non-blocking fashion.Modifier and Type | Class and Description |
---|---|
static class |
FeedableBodyGenerator.BaseFeeder
Base class for
FeedableBodyGenerator.Feeder implementations. |
static interface |
FeedableBodyGenerator.Feeder
Specifies the functionality all Feeders must implement.
|
static class |
FeedableBodyGenerator.NonBlockingFeeder
Implementations of this class provide the framework to read data from
some source and feed data to the
FeedableBodyGenerator
without blocking. |
static class |
FeedableBodyGenerator.SimpleFeeder
This simple
FeedableBodyGenerator.Feeder implementation allows the implementation to
feed data in whatever fashion is deemed appropriate. |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT
Defer to whatever the connection has been configured for max pending bytes.
|
static int |
UNBOUND
There is no limit on bytes waiting to be written.
|
Constructor and Description |
---|
FeedableBodyGenerator() |
Modifier and Type | Method and Description |
---|---|
Body |
createBody()
Creates a new instance of the request body to be read.
|
void |
setFeeder(FeedableBodyGenerator.Feeder feeder)
Add a
FeedableBodyGenerator.Feeder implementation that will be invoked when writing
without blocking is possible. |
void |
setMaxPendingBytes(int maxPendingBytes)
Configured the maximum number of bytes that may be pending to be written
to the wire.
|
public static final int UNBOUND
public static final int DEFAULT
public Body createBody() throws IOException
BodyGenerator
createBody
in interface BodyGenerator
null
.IOException
- If the body could not be created.public void setMaxPendingBytes(int maxPendingBytes)
maxPendingBytes
- maximum number of bytes that may be queued to
be written to the wire.IllegalStateException
- if called after initializeAsynchronousTransfer(FilterChainContext, HttpRequestPacket)
has been called by the GrizzlyAsyncHttpProvider
.IllegalArgumentException
- if maxPendingBytes is less than zero and is
not UNBOUND
or DEFAULT
.public void setFeeder(FeedableBodyGenerator.Feeder feeder)
FeedableBodyGenerator.Feeder
implementation that will be invoked when writing
without blocking is possible. This method must be set before dispatching
the request this feeder is associated with.feeder
- the FeedableBodyGenerator.Feeder
responsible for providing data.IllegalStateException
- if called after initializeAsynchronousTransfer(FilterChainContext, HttpRequestPacket)
has been called by the GrizzlyAsyncHttpProvider
.IllegalArgumentException
- if feeder
is null
Copyright © 2014. All Rights Reserved.