org.glassfish.grizzly.http.server.io
Interface NIOOutputSink

All Known Subinterfaces:
BinaryNIOOutputSink
All Known Implementing Classes:
NIOOutputStream, NIOWriter

public interface NIOOutputSink

This interface defines methods to allow an OutputStream or Writer to allow the developer to check with the runtime whether or not it's possible to write a certain amount of data, or if it's not possible, to be notified when it is.

Since:
2.0

Method Summary
 boolean canWrite(int length)
           
 boolean notifyCanWrite(WriteHandler handler, int length)
          Instructs the NIOOutputSink to invoke the provided WriteHandler when it is possible to write length bytes.
 

Method Detail

notifyCanWrite

boolean notifyCanWrite(WriteHandler handler,
                       int length)
Instructs the NIOOutputSink to invoke the provided WriteHandler when it is possible to write length bytes. Note that once the WriteHandler has been notified, it will not be considered for notification again at a later point in time.

Parameters:
handler - the WriteHandler that should be notified when it's possible to write length bytes.
length - the number of bytes that require writing.
Returns:
true if the specified handler has been accepted and will be notified as it becomes possible to write, otherwise returns false which means data is currently available to write without blocking or that there is no limit as to how much data can be pending to be written.
Throws:
java.lang.IllegalStateException - if this method is invoked and a handler from a previous invocation is still present (due to not having yet been notified).

canWrite

boolean canWrite(int length)
Parameters:
length - specifies the number of bytes that require writing
Returns:
true if a write to this NIOOutputSink will succeed, otherwise returns false.


Copyright © 2011 Oracle Corpration. All Rights Reserved.