Class ChannelsPair

java.lang.Object
org.jppf.utils.Pair<JMXContext,JMXContext>
org.jppf.jmxremote.nio.ChannelsPair
All Implemented Interfaces:
Serializable, org.jppf.nio.CloseableContext, org.jppf.nio.NioChannelHandler

public class ChannelsPair extends org.jppf.utils.Pair<JMXContext,JMXContext> implements org.jppf.nio.NioChannelHandler, org.jppf.nio.CloseableContext
Convenience class to group a pair of channels respectively reading from and writing to the same socket channel.
Author:
Laurent Cohen
See Also:
  • Constructor Details

  • Method Details

    • readingContext

      public JMXContext readingContext()
      Returns:
      the reading channel.
    • writingContext

      public JMXContext writingContext()
      Returns:
      the writing channel.
    • close

      public void close(Exception exception) throws Exception
      Close the channels and the underlying socket channel.
      Parameters:
      exception - an optional exception that may have cause the close, may be null.
      Throws:
      Exception - if any error occurs.
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface org.jppf.nio.CloseableContext
    • setClosed

      public void setClosed(boolean closed)
      This implementation does not do anything.
      Specified by:
      setClosed in interface org.jppf.nio.CloseableContext
    • requestClose

      public void requestClose()
      Request a close of this channel.
    • isClosing

      public boolean isClosing()
      Returns:
      whether the channels are closing.
    • getConnectionID

      public String getConnectionID()
      Returns:
      the connection identifier.
    • setConnectionID

      public ChannelsPair setConnectionID(String connectionID)
      Set the connection identifier.
      Parameters:
      connectionID - the connection id to set.
      Returns:
      this ChannelsPair, for method call chaining.
    • isServerSide

      public boolean isServerSide()
      Returns:
      whether this pair of channels represents a server-side connection.
    • setServerSide

      public void setServerSide(boolean serverSide)
      Set whether this pair of channels represents a server-side connection.
      Parameters:
      serverSide - true for a server-side connection, false otherwise.
    • getServerPort

      public int getServerPort()
      Returns:
      the server port on which the connection was established.
    • setServerPort

      public void setServerPort(int serverPort)
      Set the server port on which the connection was established.
      Parameters:
      serverPort - the port number.
    • getJxmConnectorServer

      public JPPFJMXConnectorServer getJxmConnectorServer()
      Returns:
      the associated JMXConnectorServer (server-side), if any.
    • setJxmConnectorServer

      public void setJxmConnectorServer(JPPFJMXConnectorServer connectorServer)
      Set the associated MBeanServer (server-side).
      Parameters:
      connectorServer - a JPPFJMXConnectorServer instance.
    • getJMXConnector

      public JPPFJMXConnector getJMXConnector()
      Returns:
      the associated JMXConnector (client-side).
    • setJMXConnector

      public void setJMXConnector(JPPFJMXConnector mbeanServerConnection)
      Set the associated JMXConnector (client-side).
      Parameters:
      mbeanServerConnection - the JMXConnector to set.
    • toString

      public String toString()
      Overrides:
      toString in class org.jppf.utils.Pair<JMXContext,JMXContext>
    • getInterestOps

      public int getInterestOps()
      Specified by:
      getInterestOps in interface org.jppf.nio.NioChannelHandler
    • setInterestOps

      public void setInterestOps(int interestOps)
      Specified by:
      setInterestOps in interface org.jppf.nio.NioChannelHandler
    • getSelectionKey

      public SelectionKey getSelectionKey()
      Specified by:
      getSelectionKey in interface org.jppf.nio.NioChannelHandler
    • setSelectionKey

      public void setSelectionKey(SelectionKey selectionKey)
      Specified by:
      setSelectionKey in interface org.jppf.nio.NioChannelHandler
    • getMessageHandler

      public JMXMessageHandler getMessageHandler()
      Returns:
      the associated message handler.
    • setMessageHandler

      public void setMessageHandler(JMXMessageHandler messageHandler)
      Set the associated message handler.
      Parameters:
      messageHandler - the message handler to set.
    • addCloseCallback

      public void addCloseCallback(ChannelsPair.CloseCallback callback)
      Add a callback to invoke upon #close().
      Parameters:
      callback - the callback to add.
    • removeCloseCallback

      public void removeCloseCallback(ChannelsPair.CloseCallback callback)
      Remove a callback to invoke upon #close().
      Parameters:
      callback - the callback to remove.