|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.http.server.io.OutputBuffer
public class OutputBuffer
Abstraction exposing both byte and character methods to write content to the HTTP messaging system in Grizzly.
| Nested Class Summary | |
|---|---|
static interface |
OutputBuffer.LifeCycleListener
|
| Constructor Summary | |
|---|---|
OutputBuffer()
|
|
| Method Summary | |
|---|---|
void |
acknowledge()
Acknowledge a HTTP Expect header. |
boolean |
canWrite(int length)
|
boolean |
canWriteChar(int length)
|
void |
close()
|
void |
endRequest()
|
void |
flush()
Flush the response. |
int |
getBufferedDataSize()
Get the number of bytes buffered on OutputBuffer and ready to be sent. |
int |
getBufferSize()
|
void |
initialize(Response response,
FilterChainContext ctx)
|
boolean |
isAsyncEnabled()
Returns true if content will be written in a non-blocking
fashion, otherwise returns false. |
boolean |
isClosed()
|
void |
notifyCanWrite(WriteHandler handler,
int length)
|
void |
prepareCharacterEncoder()
|
void |
recycle()
Recycle the output buffer. |
void |
registerLifeCycleListener(OutputBuffer.LifeCycleListener listener)
|
boolean |
removeLifeCycleListener(OutputBuffer.LifeCycleListener listener)
|
void |
reset()
Reset current response. |
void |
sendfile(java.io.File file,
CompletionHandler<WriteResult> handler)
Calls write(file, 0, file.length()). |
void |
sendfile(java.io.File file,
long offset,
long length,
CompletionHandler<WriteResult> handler)
Will use FileChannel.transferTo(long, long, java.nio.channels.WritableByteChannel)
to send file to the remote endpoint. |
void |
setAsyncEnabled(boolean asyncEnabled)
Sets the asynchronous processing state of this OutputBuffer. |
void |
setBufferSize(int bufferSize)
|
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(char[] cbuf)
|
void |
write(char[] cbuf,
int off,
int len)
|
void |
write(java.lang.String str)
|
void |
write(java.lang.String str,
int off,
int len)
|
void |
writeBuffer(Buffer buffer)
Writes the contents of the specified Buffer to the client. |
void |
writeByte(int b)
|
void |
writeByteBuffer(java.nio.ByteBuffer byteBuffer)
Writes the contents of the specified ByteBuffer to the client. |
void |
writeChar(int c)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OutputBuffer()
| Method Detail |
|---|
public void initialize(Response response,
FilterChainContext ctx)
public boolean isAsyncEnabled()
Returns true if content will be written in a non-blocking
fashion, otherwise returns false.
true if content will be written in a non-blocking
fashion, otherwise returns false.public void setAsyncEnabled(boolean asyncEnabled)
OutputBuffer.
asyncEnabled - true if this OutputBuffer
will write content without blocking.- Since:
- 2.1.2
public void prepareCharacterEncoder()
public int getBufferSize()
public void registerLifeCycleListener(OutputBuffer.LifeCycleListener listener)
public boolean removeLifeCycleListener(OutputBuffer.LifeCycleListener listener)
public void setBufferSize(int bufferSize)
public void reset()
java.lang.IllegalStateException - if the response has already been committedpublic boolean isClosed()
true if this OutputBuffer is closed, otherwise
returns false.public int getBufferedDataSize()
public void recycle()
public void endRequest()
throws java.io.IOException
java.io.IOException
public void acknowledge()
throws java.io.IOException
Expect header. The response status
code and reason phrase should be set before invoking this method.
java.io.IOException - if an error occurs writing the acknowledgment.
public void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
java.io.IOException
public void writeChar(int c)
throws java.io.IOException
java.io.IOException
public void write(char[] cbuf)
throws java.io.IOException
java.io.IOException
public void write(java.lang.String str)
throws java.io.IOException
java.io.IOException
public void write(java.lang.String str,
int off,
int len)
throws java.io.IOException
java.io.IOException
public void writeByte(int b)
throws java.io.IOException
java.io.IOException
public void write(byte[] b)
throws java.io.IOException
java.io.IOException
public void sendfile(java.io.File file,
CompletionHandler<WriteResult> handler)
throws java.io.IOException
Calls write(file, 0, file.length()).
file - the File to transfer.handler - CompletionHandler that will be notified
of the transfer progress/completion or failure.
java.io.IOException - if an error occurs during the transfer
java.lang.IllegalArgumentException - if file is nullsendfile(java.io.File, long, long, org.glassfish.grizzly.CompletionHandler)
public void sendfile(java.io.File file,
long offset,
long length,
CompletionHandler<WriteResult> handler)
throws java.io.IOException
Will use FileChannel.transferTo(long, long, java.nio.channels.WritableByteChannel)
to send file to the remote endpoint. Note that all headers necessary
for the file transfer must be set prior to invoking this method as this will
case the HTTP header to be flushed to the client prior to sending the file
content. This should also be the last call to write any content to the remote
endpoint.
It's required that the response be suspended when using this functionality. It will be assumed that if the response wasn't suspended when this method is called, that it's desired that this method manages the suspend/resume cycle.
file - the File to transfer.offset - the starting offset within the Filelength - the total number of bytes to transferhandler - CompletionHandler that will be notified
of the transfer progress/completion or failure.
java.io.IOException - if an error occurs during the transfer
java.io.IOException - if an I/O error occurs
java.lang.IllegalArgumentException - if the response has already been committed
at the time this method was invoked.
java.lang.IllegalStateException - if a file transfer request has already
been made or if send file support isn't
available.
java.lang.IllegalStateException - if the response was in a suspended state
when this method was invoked, but no
CompletionHandler was provided.
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
java.io.IOException
public void close()
throws java.io.IOException
java.io.IOException
public void flush()
throws java.io.IOException
java.io.IOException - an underlying I/O error occurred
public void writeByteBuffer(java.nio.ByteBuffer byteBuffer)
throws java.io.IOException
Writes the contents of the specified ByteBuffer to the client.
ByteBuffer will be directly used by underlying
connection, so it could be reused only if it has been flushed.
byteBuffer - the ByteBuffer to write
java.io.IOException - if an error occurs during the write
public void writeBuffer(Buffer buffer)
throws java.io.IOException
Writes the contents of the specified Buffer to the client.
Buffer will be directly used by underlying
connection, so it could be reused only if it has been flushed.
buffer - the Buffer to write
java.io.IOException - if an error occurs during the writepublic boolean canWriteChar(int length)
public boolean canWrite(int length)
AsyncQueueWriter.canWrite(org.glassfish.grizzly.Connection, int)
public void notifyCanWrite(WriteHandler handler,
int length)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||