Package org.jppf.nio

Class NioMessageWriter<C extends AbstractNioContext>

java.lang.Object
org.jppf.nio.NioMessageWriter<C>
Type Parameters:
C - the type of connection context.

public abstract class NioMessageWriter<C extends AbstractNioContext> extends Object
Writes all messages in the channel's context queue, if any, or keeps writing the current message until the socket send buffer is full.
Author:
Laurent Cohen
  • Field Details

  • Constructor Details

    • NioMessageWriter

      public NioMessageWriter(StatelessNioServer<C> server)
      Initialize this message writer.
      Parameters:
      server - the nio server.
  • Method Details

    • write

      protected boolean write(C context) throws Exception
      Write to the specified channel.
      Parameters:
      context - the context to write to.
      Returns:
      true if there is more to write, but the socket send buffer is full, false otherwise.
      Throws:
      Exception - if any errort occurs.
    • doWrite

      protected boolean doWrite(C context) throws Exception
      Write to the specified channel.
      Parameters:
      context - the context to write to.
      Returns:
      true if there is more to write, but the socket send buffer is full, false otherwise.
      Throws:
      Exception - if any error occurs.
    • preWrite

      protected void preWrite(C context, NioMessage data) throws Exception
      Method called just before a message is sent to the remote peer.
      Parameters:
      context - the context that sent the message.
      data - the message sent.
      Throws:
      Exception - if any error occurs.
    • postWrite

      protected abstract void postWrite(C context, NioMessage data) throws Exception
      Method called after a message is sent to the remote peer.
      Parameters:
      context - the context that sent the message.
      data - the message sent.
      Throws:
      Exception - if any error occurs.