Package org.jppf.jmxremote.nio
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA callback invoked upon closing the connection. -
Field Summary
Fields inherited from class org.jppf.utils.Pair
first, second -
Constructor Summary
ConstructorsConstructorDescriptionChannelsPair(JMXContext first, JMXContext second, JMXNioServer server, JMXAuthenticator authenticator) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCloseCallback(ChannelsPair.CloseCallback callback) Add a callback to invoke upon#close().voidClose the channels and the underlying socket channel.intintbooleanisClosed()booleanbooleanvoidRemove a callback to invoke upon#close().voidRequest a close of this channel.voidsetClosed(boolean closed) This implementation does not do anything.setConnectionID(String connectionID) Set the connection identifier.voidsetInterestOps(int interestOps) voidsetJMXConnector(JPPFJMXConnector mbeanServerConnection) Set the associated JMXConnector (client-side).voidsetJxmConnectorServer(JPPFJMXConnectorServer connectorServer) Set the associated MBeanServer (server-side).voidsetMessageHandler(JMXMessageHandler messageHandler) Set the associated message handler.voidsetSelectionKey(SelectionKey selectionKey) voidsetServerPort(int serverPort) Set the server port on which the connection was established.voidsetServerSide(boolean serverSide) Set whether this pair of channels represents a server-side connection.toString()Methods inherited from class org.jppf.utils.Pair
equals, first, hashCode, left, right, second
-
Constructor Details
-
ChannelsPair
public ChannelsPair(JMXContext first, JMXContext second, JMXNioServer server, JMXAuthenticator authenticator) - Parameters:
first- the reading channel.second- the writing channel.server- the JMX nio server.authenticator- an optionalJMXAuthenticator(server-side only).
-
-
Method Details
-
readingContext
- Returns:
- the reading channel.
-
writingContext
- Returns:
- the writing channel.
-
close
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:
isClosedin interfaceorg.jppf.nio.CloseableContext
-
setClosed
public void setClosed(boolean closed) This implementation does not do anything.- Specified by:
setClosedin interfaceorg.jppf.nio.CloseableContext
-
requestClose
public void requestClose()Request a close of this channel. -
isClosing
public boolean isClosing()- Returns:
- whether the channels are closing.
-
getConnectionID
- Returns:
- the connection identifier.
-
setConnectionID
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-truefor a server-side connection,falseotherwise.
-
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
- Returns:
- the associated JMXConnectorServer (server-side), if any.
-
setJxmConnectorServer
Set the associated MBeanServer (server-side).- Parameters:
connectorServer- aJPPFJMXConnectorServerinstance.
-
getJMXConnector
- Returns:
- the associated JMXConnector (client-side).
-
setJMXConnector
Set the associated JMXConnector (client-side).- Parameters:
mbeanServerConnection- theJMXConnectorto set.
-
toString
- Overrides:
toStringin classorg.jppf.utils.Pair<JMXContext,JMXContext>
-
getInterestOps
public int getInterestOps()- Specified by:
getInterestOpsin interfaceorg.jppf.nio.NioChannelHandler
-
setInterestOps
public void setInterestOps(int interestOps) - Specified by:
setInterestOpsin interfaceorg.jppf.nio.NioChannelHandler
-
getSelectionKey
- Specified by:
getSelectionKeyin interfaceorg.jppf.nio.NioChannelHandler
-
setSelectionKey
- Specified by:
setSelectionKeyin interfaceorg.jppf.nio.NioChannelHandler
-
getMessageHandler
- Returns:
- the associated message handler.
-
setMessageHandler
Set the associated message handler.- Parameters:
messageHandler- the message handler to set.
-
addCloseCallback
Add a callback to invoke upon#close().- Parameters:
callback- the callback to add.
-
removeCloseCallback
Remove a callback to invoke upon#close().- Parameters:
callback- the callback to remove.
-