org.khelekore.rnio.impl
Class SimpleBlockSender

java.lang.Object
  extended by org.khelekore.rnio.impl.SocketHandlerBase<SocketChannel>
      extended by org.khelekore.rnio.impl.SimpleBlockSender
All Implemented Interfaces:
SocketChannelHandler, WriteHandler

public abstract class SimpleBlockSender
extends SocketHandlerBase<SocketChannel>
implements WriteHandler

A simple sender of data. Will try to send all data with no timeout.

Subclass this sender and implement done() to do any work after the data has been sent.

Author:
Robert Olofsson

Field Summary
 
Fields inherited from class org.khelekore.rnio.impl.SocketHandlerBase
nioHandler, sc, timeout
 
Constructor Summary
SimpleBlockSender(SocketChannel sc, NioHandler nioHandler, ByteBuffer buf, Long timeout)
           
 
Method Summary
 void done()
          The default is to do nothing, override in subclasses if needed.
 ByteBuffer getBuffer()
          Get the buffer we are sending data from.
 void handleIOException(IOException e)
          Handle the exception, default is to log it and to close the channel.
 void register()
          Register writeWait on the nioHandler
 void write()
          The channel is ready for read.
 
Methods inherited from class org.khelekore.rnio.impl.SocketHandlerBase
closed, getDescription, getTimeout, timeout, useSeparateThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.khelekore.rnio.SocketChannelHandler
closed, getDescription, getTimeout, timeout, useSeparateThread
 

Constructor Detail

SimpleBlockSender

public SimpleBlockSender(SocketChannel sc,
                         NioHandler nioHandler,
                         ByteBuffer buf,
                         Long timeout)
Parameters:
sc - the channel to handle
nioHandler - the NioHandler
buf - the ByteBuffer to send
timeout - the timeout in millis, may be null if no timeout is wanted.
Method Detail

getBuffer

public ByteBuffer getBuffer()
Get the buffer we are sending data from.


write

public void write()
Description copied from interface: WriteHandler
The channel is ready for read.

Specified by:
write in interface WriteHandler

handleIOException

public void handleIOException(IOException e)
Handle the exception, default is to log it and to close the channel.


done

public void done()
The default is to do nothing, override in subclasses if needed.


register

public void register()
Register writeWait on the nioHandler