mirrormap.nio
Class TcpServer

java.lang.Object
  extended by mirrormap.lifecycle.AbstractLifeCycle
      extended by mirrormap.nio.TcpServer
All Implemented Interfaces:
IDestroyable, ILifeCycle

public class TcpServer
extends AbstractLifeCycle

A server that opens a TCP server socket and spawns TcpConnectionEndPoint instances to handle each of the client connections.

Author:
Ramon Servadei

Field Summary
static String CONTEXT_RCV_BUFFER
          The system property for overriding the default receive buffer size for the server port.
static int DEFAULT_TCP_PORT
          The default TCP port
static String HOST_NAME
          The host name
 
Constructor Summary
TcpServer(IConnectionEndPointReceiver.IFactory endPointReceiverFactory, String address, int port)
          Construct the server with the factory that will create the IConnectionEndPointReceiver per client socket connection and the server socket address and port
 
Method Summary
protected  void doDestroy()
          Overridden in subclasses to perform custom logic on destruction.
protected  void doStart()
          Overridden in subclasses to perform custom logic on activation.
 String toString()
           
 
Methods inherited from class mirrormap.lifecycle.AbstractLifeCycle
checkActive, destroy, finalize, isActive, start
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTEXT_RCV_BUFFER

public static final String CONTEXT_RCV_BUFFER
The system property for overriding the default receive buffer size for the server port. This must be specified in units of bytes.

See Also:
Constant Field Values

DEFAULT_TCP_PORT

public static final int DEFAULT_TCP_PORT
The default TCP port

See Also:
Constant Field Values

HOST_NAME

public static final String HOST_NAME
The host name

Constructor Detail

TcpServer

public TcpServer(IConnectionEndPointReceiver.IFactory endPointReceiverFactory,
                 String address,
                 int port)
Construct the server with the factory that will create the IConnectionEndPointReceiver per client socket connection and the server socket address and port

Parameters:
endPointReceiverFactory - the factory to create the IConnectionEndPointReceiver for each client socket
address - the server socket address or host name
port - the server socket TCP port
Method Detail

toString

public String toString()
Overrides:
toString in class AbstractLifeCycle

doDestroy

protected void doDestroy()
Description copied from class: AbstractLifeCycle
Overridden in subclasses to perform custom logic on destruction. Any exceptions should be thrown as a RuntimeException or subclass thereof.

Specified by:
doDestroy in class AbstractLifeCycle

doStart

protected void doStart()
Description copied from class: AbstractLifeCycle
Overridden in subclasses to perform custom logic on activation. Any exceptions should be thrown as a RuntimeException or subclass thereof. When this method is called, the AbstractLifeCycle.isActive() method will return true.

Specified by:
doStart in class AbstractLifeCycle


Copyright © 2010. All Rights Reserved.