The Meta-Environment API

toolbus.communication
Class AbstractConnectionHandler

java.lang.Object
  extended by toolbus.communication.AbstractConnectionHandler
Direct Known Subclasses:
SocketConnectionHandler, ToolConnectionHandler

public abstract class AbstractConnectionHandler
extends java.lang.Object

Interface that defines all methods that are required for connection handlers. They need to facilitate in obtaining a reference to read and write multiplexers and supply methods for closing a connection.

Author:
Arnold Lankamp

Constructor Summary
AbstractConnectionHandler()
           
 
Method Summary
abstract  void closeConnection(java.nio.channels.SocketChannel socketChannel)
          Closes the connection associated with the given socket channel.
 void closeDueToDisconnect(java.nio.channels.SocketChannel socketChannel, SocketIOHandler socketIOHandler)
          Closes the connection associated with the given socket channel.
 void closeDueToException(java.nio.channels.SocketChannel socketChannel, SocketIOHandler socketIOHandler)
          Closes the connection associated with the given socket channel.
abstract  IReadMultiplexer getReadMultiplexer()
          Returns a reference to the read multiplexer.
abstract  IWriteMultiplexer getWriteMultiplexer()
          Returns a reference to the write multiplexer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConnectionHandler

public AbstractConnectionHandler()
Method Detail

getReadMultiplexer

public abstract IReadMultiplexer getReadMultiplexer()
Returns a reference to the read multiplexer.

Returns:
A reference to the read multiplexer.

getWriteMultiplexer

public abstract IWriteMultiplexer getWriteMultiplexer()
Returns a reference to the write multiplexer.

Returns:
A reference to the write multiplexer.

closeConnection

public abstract void closeConnection(java.nio.channels.SocketChannel socketChannel)
Closes the connection associated with the given socket channel. This method executes a controlled shutdown of the connection. The socket channel will be deregistered (if needed) and will be closed.

Parameters:
socketChannel - The socket channel, who's associated socket should be closed.

closeDueToException

public void closeDueToException(java.nio.channels.SocketChannel socketChannel,
                                SocketIOHandler socketIOHandler)
Closes the connection associated with the given socket channel. This method should be invoked after an error occurs during the usage of a socket / socket channel.

Parameters:
socketChannel - The socket channel, who's associated socket should be closed.
socketIOHandler - The socket I/O handler associated with the connection that was disconnected.

closeDueToDisconnect

public void closeDueToDisconnect(java.nio.channels.SocketChannel socketChannel,
                                 SocketIOHandler socketIOHandler)
Closes the connection associated with the given socket channel. This method should be invoked when an unexpected disconnect occurred on the given socket / socket channel.

Parameters:
socketChannel - The socket channel, who's associated socket should be closed.
socketIOHandler - The socket I/O handler associated with the connection that was disconnected.

The Meta-Environment API