com.ning.http.client.providers.grizzly
Class FeedableBodyGenerator.NonBlockingFeeder

java.lang.Object
  extended by com.ning.http.client.providers.grizzly.FeedableBodyGenerator.BaseFeeder
      extended by com.ning.http.client.providers.grizzly.FeedableBodyGenerator.NonBlockingFeeder
All Implemented Interfaces:
FeedableBodyGenerator.Feeder
Enclosing class:
FeedableBodyGenerator

public abstract static class FeedableBodyGenerator.NonBlockingFeeder
extends FeedableBodyGenerator.BaseFeeder

Implementations of this class provide the framework to read data from some source and feed data to the FeedableBodyGenerator without blocking.


Nested Class Summary
static interface FeedableBodyGenerator.NonBlockingFeeder.ReadyToFeedListener
          Listener to signal that data is available to be fed.
 
Field Summary
 
Fields inherited from class com.ning.http.client.providers.grizzly.FeedableBodyGenerator.BaseFeeder
feedableBodyGenerator
 
Constructor Summary
FeedableBodyGenerator.NonBlockingFeeder(FeedableBodyGenerator feedableBodyGenerator)
          Constructs the NonBlockingFeeder with the associated FeedableBodyGenerator.
 
Method Summary
abstract  void canFeed()
          Notification that it's possible to send another block of data via FeedableBodyGenerator.BaseFeeder.feed(org.glassfish.grizzly.Buffer, boolean).
 void flush()
          This method will be invoked when it's possible to begin feeding data downstream.
abstract  boolean isDone()
           
abstract  boolean isReady()
           
abstract  void notifyReadyToFeed(FeedableBodyGenerator.NonBlockingFeeder.ReadyToFeedListener listener)
          Callback registration to signal the FeedableBodyGenerator that data is available once again to continue feeding.
 
Methods inherited from class com.ning.http.client.providers.grizzly.FeedableBodyGenerator.BaseFeeder
feed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeedableBodyGenerator.NonBlockingFeeder

public FeedableBodyGenerator.NonBlockingFeeder(FeedableBodyGenerator feedableBodyGenerator)
Constructs the NonBlockingFeeder with the associated FeedableBodyGenerator.

Method Detail

canFeed

public abstract void canFeed()
                      throws IOException
Notification that it's possible to send another block of data via FeedableBodyGenerator.BaseFeeder.feed(org.glassfish.grizzly.Buffer, boolean). It's important to only invoke FeedableBodyGenerator.BaseFeeder.feed(Buffer, boolean) once per invocation of canFeed().

Throws:
IOException

isDone

public abstract boolean isDone()
Returns:
true if all data has been fed by this feeder, otherwise returns false.

isReady

public abstract boolean isReady()
Returns:
true if data is available to be fed, otherwise returns false. When this method returns false, the FeedableBodyGenerator will call notifyReadyToFeed(ReadyToFeedListener) by which this FeedableBodyGenerator.NonBlockingFeeder implementation may signal data is once again available to be fed.

notifyReadyToFeed

public abstract void notifyReadyToFeed(FeedableBodyGenerator.NonBlockingFeeder.ReadyToFeedListener listener)
Callback registration to signal the FeedableBodyGenerator that data is available once again to continue feeding. Once this listener has been invoked, the NonBlockingFeeder implementation should no longer maintain a reference to the listener.


flush

public void flush()
           throws IOException
This method will be invoked when it's possible to begin feeding data downstream. Implementations of this method must use FeedableBodyGenerator.Feeder.feed(Buffer, boolean) to perform the actual write.

Throws:
IOException - if an I/O error occurs.


Copyright © 2014. All Rights Reserved.