Package org.jppf.nio

Class AbstractNioMessage

java.lang.Object
org.jppf.nio.AbstractNioMessageBase
org.jppf.nio.AbstractNioMessage
All Implemented Interfaces:
NioMessage
Direct Known Subclasses:
ClassLoaderNioMessage

public abstract class AbstractNioMessage extends AbstractNioMessageBase
Common abstract superclass representing a message sent or received by a channel. A message is the transformation of a sequence of objects into a more easily transportable format.
Author:
Laurent Cohen
  • Field Details

    • locations

      protected final List<DataLocation> locations
      The data location objects abstracting the data to send or receive.
    • position

      protected int position
      The current position in the list of data locations.
    • nbObjects

      protected int nbObjects
      The number of objects to read or write.
  • Constructor Details

    • AbstractNioMessage

      protected AbstractNioMessage(NioContext channel)
      Initialize this nio message.
      Parameters:
      channel - the channel to read from or write to.
  • Method Details

    • addLocation

      public void addLocation(DataLocation location)
      Add a location to the data locations of this message.
      Parameters:
      location - the location to add.
    • read

      public boolean read() throws Exception
      Description copied from interface: NioMessage
      Read data from a channel.
      Returns:
      true if the data has been completely read from the channel, false otherwise.
      Throws:
      Exception - if an IO error occurs.
    • write

      public boolean write() throws Exception
      Description copied from interface: NioMessage
      Read data from a channel.
      Returns:
      true if the data has been completely written the channel, false otherwise.
      Throws:
      Exception - if an IO error occurs.
    • readNextObject

      protected boolean readNextObject() throws Exception
      Read the next serializable object from the specified channel.
      Returns:
      true if the object has been completely read from the channel, false otherwise.
      Throws:
      Exception - if an IO error occurs.
    • writeNextObject

      protected boolean writeNextObject() throws Exception
      Write the next object to the specified channel.
      Returns:
      true if the object has been completely written the channel, false otherwise.
      Throws:
      Exception - if an IO error occurs.
    • getLocations

      public List<DataLocation> getLocations()
      Get the data location objects abstracting the data to send or receive.
      Returns:
      a list of DataLocation objects.
    • afterFirstRead

      protected void afterFirstRead() throws Exception
      Actions to take after the first object in the message has been fully read.
      Throws:
      Exception - if an IO error occurs.
    • beforeFirstWrite

      protected void beforeFirstWrite() throws Exception
      Actions to take before the first object in the message is written.
      Throws:
      Exception - if an IO error occurs.
    • toString

      public String toString()
      Overrides:
      toString in class Object