fabric.common
Class AbstractConnectionHandler<Node,Session extends AbstractMessageHandlerThread.SessionAttributes,MessageHandlerThread extends AbstractMessageHandlerThread<Session,MessageHandlerThread>>

java.lang.Object
  extended by fabric.common.AbstractConnectionHandler<Node,Session,MessageHandlerThread>
Type Parameters:
Node - a class for representing the nodes that can be connected to.
Session - a class of session objects.
Direct Known Subclasses:
ConnectionHandler

public abstract class AbstractConnectionHandler<Node,Session extends AbstractMessageHandlerThread.SessionAttributes,MessageHandlerThread extends AbstractMessageHandlerThread<Session,MessageHandlerThread>>
extends java.lang.Object

Abstraction for initializing incoming network connections and handing them off to a ChannelMultiplexerThread.

See Also:
CommManager.connect()

Constructor Summary
protected AbstractConnectionHandler(int poolSize, AbstractMessageHandlerThread.Factory<MessageHandlerThread> handlerFactory)
           
 
Method Summary
protected abstract  Node getNodeByName(java.lang.String name)
           
protected abstract  java.lang.String getThreadName(java.net.SocketAddress remote, Session session)
          Returns the name for the message-handler thread that will be handling the given connection.
 void handle(java.nio.channels.SocketChannel connection)
           
protected abstract  void logAuthenticationFailure()
          Logs an authentication failure of the remote host.
protected abstract  void logSession(java.net.SocketAddress remote, Session session)
          Logs a successful connection.
protected abstract  Session newAuthenticatedSession(Node node, java.lang.String remoteNodeName, java.lang.String remoteNodePrincipalName, NodePrincipal remoteNodePrincipal)
           
protected  Session newUnauthenticatedSession(Node node, java.lang.String remoteNodeName)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConnectionHandler

protected AbstractConnectionHandler(int poolSize,
                                    AbstractMessageHandlerThread.Factory<MessageHandlerThread> handlerFactory)
Method Detail

getNodeByName

protected abstract Node getNodeByName(java.lang.String name)
Returns:
an object representing the node with the given name. Can be null if the node doesn't exist at this host.

newUnauthenticatedSession

protected Session newUnauthenticatedSession(Node node,
                                            java.lang.String remoteNodeName)
Parameters:
node - the local node with which the session was established.
remoteNodeName - the name of the remote node.
Returns:
a Session object representing an unauthenticated, unencrypted session. A null value is returned if this node doesn't support this type of session.

newAuthenticatedSession

protected abstract Session newAuthenticatedSession(Node node,
                                                   java.lang.String remoteNodeName,
                                                   java.lang.String remoteNodePrincipalName,
                                                   NodePrincipal remoteNodePrincipal)
Parameters:
node - the local node with which the session was established.
remoteNodeName - the name of the remote node.
remoteNodePrincipalName - the String representation of the remote node's principal.
remoteNodePrincipal - the NodePrincipal corresponding to the remote node.
Returns:
a Session object representing an authenticated, encrypted session.

logAuthenticationFailure

protected abstract void logAuthenticationFailure()
Logs an authentication failure of the remote host.


logSession

protected abstract void logSession(java.net.SocketAddress remote,
                                   Session session)
Logs a successful connection.


getThreadName

protected abstract java.lang.String getThreadName(java.net.SocketAddress remote,
                                                  Session session)
Returns the name for the message-handler thread that will be handling the given connection.


handle

public final void handle(java.nio.channels.SocketChannel connection)

shutdown

public final void shutdown()