org.jppf.server.nio
Class AbstractSocketChannelHandler

java.lang.Object
  extended by org.jppf.server.nio.AbstractSocketChannelHandler
Direct Known Subclasses:
MultiplexerChannelHandler, MultiplexerChannelHandler, OutboundChannelHandler, OutboundChannelHandler, PeerResourceProvider

public abstract class AbstractSocketChannelHandler
extends Object

Instances of this class act as wrapper for a connection to a JPPF component.
They handle (re)connection services when needed.

Author:
Laurent Cohen

Field Summary
protected  String host
          The remote host to connect to.
protected  int port
          Port to connect to on the remote host.
protected  NioServer server
          The NioServer to which the channel is registred.
protected  SocketChannelClient socketClient
          Wrapper around the underlying socket connection.
protected  SocketInitializer socketInitializer
          Used to synchronize access to the underlying socket from multiple threads.
 
Constructor Summary
AbstractSocketChannelHandler(NioServer server)
          Initialize this socket channel handler.
AbstractSocketChannelHandler(NioServer server, String host, int port)
          Initialize the channel with the specified host and port.
 
Method Summary
 SocketChannelClient getSocketClient()
          Get the wrapper around the underlying socket connection.
 void init()
          Initialize this node's resources.
protected abstract  SocketChannelClient initSocketChannel()
          Initialize the channel client.
protected abstract  void postInit()
          This method is called after the channel is successfully conntected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected NioServer server
The NioServer to which the channel is registred.


host

protected String host
The remote host to connect to.


port

protected int port
Port to connect to on the remote host.


socketClient

protected SocketChannelClient socketClient
Wrapper around the underlying socket connection.


socketInitializer

protected SocketInitializer socketInitializer
Used to synchronize access to the underlying socket from multiple threads.

Constructor Detail

AbstractSocketChannelHandler

public AbstractSocketChannelHandler(NioServer server)
Initialize this socket channel handler.

Parameters:
server - the NioServer to which the channel is registred.

AbstractSocketChannelHandler

public AbstractSocketChannelHandler(NioServer server,
                                    String host,
                                    int port)
Initialize the channel with the specified host and port.

Parameters:
server - the NioServer to which the channel is registred.
host - the remote host to connect to.
port - the port to connect to on the remote host.
Method Detail

init

public void init()
          throws Exception
Initialize this node's resources.

Throws:
Exception - if an error is raised during initialization.

postInit

protected abstract void postInit()
                          throws Exception
This method is called after the channel is successfully conntected.

Throws:
Exception - if an error is raised while performing the initialization.

initSocketChannel

protected abstract SocketChannelClient initSocketChannel()
                                                  throws Exception
Initialize the channel client.

Returns:
a non-connected SocketChannelClient instance.
Throws:
Exception - if an error is raised during initialization.

getSocketClient

public SocketChannelClient getSocketClient()
Get the wrapper around the underlying socket connection.

Returns:
a SocketChannelClient instance.


Copyright © 2005-2010 JPPF Team.