Interface FeedableBodyGenerator.Feeder
- All Known Implementing Classes:
FeedableBodyGenerator.BaseFeeder,FeedableBodyGenerator.NonBlockingFeeder,FeedableBodyGenerator.SimpleFeeder,NonBlockingInputStreamFeeder
- Enclosing class:
- FeedableBodyGenerator
public static interface FeedableBodyGenerator.Feeder
Specifies the functionality all Feeders must implement. Typically,
developers need not worry about implementing this interface directly.
It should be sufficient, for most use-cases, to simply use the
FeedableBodyGenerator.NonBlockingFeeder
or FeedableBodyGenerator.SimpleFeeder implementations.-
Method Summary
Modifier and TypeMethodDescriptionvoidfeed(org.glassfish.grizzly.Buffer buffer, boolean last) This method will write the specifiedBufferto the connection.voidflush()This method will be invoked when it's possible to begin feeding data downstream.voidreset()This method will be called if theBodyGeneratoris reused, as with authentication or redirect requests, so that if possible the underlying data is reset.
-
Method Details
-
flush
This method will be invoked when it's possible to begin feeding data downstream. Implementations of this method must usefeed(Buffer, boolean)to perform the actual write.- Throws:
IOException- if an I/O error occurs.
-
feed
This method will write the specifiedBufferto the connection. Be aware that this method may block depending if data is being fed faster than it can write. How much data may be queued is dictated byFeedableBodyGenerator.setMaxPendingBytes(int). Once this threshold is exceeded, the method will block until the write queue length drops below the aforementioned threshold.- Parameters:
buffer- theBufferto write.last- flag indicating if this is the last buffer to send.- Throws:
IOException- if an I/O error occurs.IllegalArgumentException- ifbufferisnull.IllegalStateException- if this method is invoked before asynchronous transferring has been initiated.- See Also:
-
reset
void reset()This method will be called if theBodyGeneratoris reused, as with authentication or redirect requests, so that if possible the underlying data is reset.
-