org.glassfish.grizzly.nio.transport
Class TCPNIOAsyncQueueWriter

java.lang.Object
  extended by org.glassfish.grizzly.AbstractWriter<SocketAddress>
      extended by org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter
          extended by org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter
All Implemented Interfaces:
AsyncQueueProcessor, AsyncQueueWriter<SocketAddress>, Processor, Writer<SocketAddress>

public class TCPNIOAsyncQueueWriter
extends AbstractNIOAsyncQueueWriter

The TCP transport AsyncQueueWriter implementation, based on the Java NIO

Author:
Alexey Stashok

Field Summary
 
Fields inherited from class org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter
transport
 
Fields inherited from interface org.glassfish.grizzly.asyncqueue.AsyncQueueProcessor
NOT_REGISTER_KEY
 
Constructor Summary
TCPNIOAsyncQueueWriter(NIOTransport transport)
           
 
Method Summary
 void afterProcess(Context context)
          Method will be called by framework after Processor execution, so it can release associated resources.
 void beforeProcess(Context context)
          Method will be called by framework before executing this Processor.
 Context context()
          Creates Context
protected  void onReadyToWrite(Connection connection)
           
 Future<WriteResult<Buffer,SocketAddress>> write(Connection connection, SocketAddress dstAddress, Buffer buffer, CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler, Interceptor<WriteResult> interceptor, MessageCloner<Buffer> cloner)
          Method writes the Buffer to the specific address.
protected  int write0(Connection connection, SocketAddress dstAddress, Buffer buffer, WriteResult<Buffer,SocketAddress> currentResult)
           
 
Methods inherited from class org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter
close, doWrite, failWriteRecord, getContextPool, isInterested, isReady, onClose, onWriteCompleted, onWriteFailure, onWriteIncompleted, process, processAsync, setInterested, write
 
Methods inherited from class org.glassfish.grizzly.AbstractWriter
write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.glassfish.grizzly.Writer
write, write, write, write, write
 

Constructor Detail

TCPNIOAsyncQueueWriter

public TCPNIOAsyncQueueWriter(NIOTransport transport)
Method Detail

write

public Future<WriteResult<Buffer,SocketAddress>> write(Connection connection,
                                                       SocketAddress dstAddress,
                                                       Buffer buffer,
                                                       CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler,
                                                       Interceptor<WriteResult> interceptor,
                                                       MessageCloner<Buffer> cloner)
                                                throws IOException
Description copied from class: AbstractNIOAsyncQueueWriter
Method writes the Buffer to the specific address.

Specified by:
write in interface AsyncQueueWriter<SocketAddress>
Overrides:
write in class AbstractNIOAsyncQueueWriter
Parameters:
connection - the Connection to write to
dstAddress - the destination address the message will be sent to
buffer - the message, from which the data will be written
completionHandler - CompletionHandler, which will get notified, when write will be completed
interceptor - Interceptor, which will be able to intercept control each time new portion of a data was written from a buffer. The interceptor can decide, whether asynchronous write is completed or not, or provide other processing instructions.
cloner - MessageCloner, which will be invoked by AsyncQueueWriter, if message could not be written to a channel directly and has to be put on a asynchronous queue
Returns:
Future, using which it's possible to check the result
Throws:
IOException

write0

protected int write0(Connection connection,
                     SocketAddress dstAddress,
                     Buffer buffer,
                     WriteResult<Buffer,SocketAddress> currentResult)
              throws IOException
Specified by:
write0 in class AbstractNIOAsyncQueueWriter
Throws:
IOException

onReadyToWrite

protected void onReadyToWrite(Connection connection)
                       throws IOException
Specified by:
onReadyToWrite in class AbstractNIOAsyncQueueWriter
Throws:
IOException

context

public Context context()
Description copied from interface: Processor
Creates Context

Returns:
Context, or null, if default Context could be used.

beforeProcess

public void beforeProcess(Context context)
                   throws IOException
Description copied from interface: Processor
Method will be called by framework before executing this Processor.

Parameters:
context - processing context
Throws:
IOException

afterProcess

public void afterProcess(Context context)
                  throws IOException
Description copied from interface: Processor
Method will be called by framework after Processor execution, so it can release associated resources.

Parameters:
context - processing context
Throws:
IOException


Copyright © 2009 SUN Microsystems. All Rights Reserved.