com.msi.network.server
Class TCPServer

java.lang.Object
  extended bycom.msi.network.server.TCPServer
All Implemented Interfaces:
java.lang.Runnable, ServerConstants
Direct Known Subclasses:
adminTCPServer

public class TCPServer
extends java.lang.Object
implements java.lang.Runnable, ServerConstants

TCPServer implements a multi-threaded ServerSocket based server. At this level the server instantiates a server socket and starts a low-level server to handle the protocol of the server itself.

Successful operation requires that the RHFactory have a registered RHBuilder for the port this thread will service.

Version:
1.0
Author:
Ken Thompson

Field Summary
private  boolean isSSL
          isSSL indicates/controls whether this is an SSL (secure) or non-SSL server.
protected  java.lang.Thread kicker
          kicker - thread management.
protected  int maxServers
          maxServers - maximum before holding off on requests
private  boolean onLine
           
protected  int port
          port - for the interface.
protected  TCPInterface TCPif
          TCPif - communications channel to client.
 
Fields inherited from interface com.msi.network.server.ServerConstants
defaultMaxServers, serverSamplePeriod
 
Constructor Summary
private TCPServer()
          Creates a new TCPServer instance.
  TCPServer(int port)
          Set up the internal state.
  TCPServer(int port, boolean isSSL)
          Creates a new TCPServer instance.
  TCPServer(int port, int maxServers)
          Creates a new TCPServer instance.
  TCPServer(int port, int maxServers, boolean isSSL)
          Creates a new TCPServer instance.
  TCPServer(int port, int maxServers, long connTO)
          Creates a new TCPServer instance.
  TCPServer(int port, int maxServers, long connTO, boolean isSSL)
          Creates a new TCPServer instance.
 
Method Summary
protected  void finalize()
          Describe finalize method here.
 int getMaxServers()
          Get the value of maxServers.
 boolean isIsSSL()
          Get the value of isSSL.
 boolean isOnLine()
          Return the current value of the onLine status.
 void run()
          Main control loop of the thread, calls runServer to perform the actual server operations.
 void runServer(Connection conn)
          Create a new requestHandler thread passing the connection and start the thread.
 void setIsSSL(boolean v)
          Set the value of isSSL.
 void setMaxServers(int v)
          Set the value of maxServers.
 void setOnLine(boolean v)
          Set the value of the online status.
 void start()
          Spawn a thread if needed and open the server socket.
 java.lang.String statsString()
          statsString - present the current state as a String.
 void stop()
          Cleanup and shutdown.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isSSL

private boolean isSSL
isSSL indicates/controls whether this is an SSL (secure) or non-SSL server.


maxServers

protected int maxServers
maxServers - maximum before holding off on requests


TCPif

protected TCPInterface TCPif
TCPif - communications channel to client.


port

protected int port
port - for the interface.


kicker

protected java.lang.Thread kicker
kicker - thread management.


onLine

private boolean onLine
Constructor Detail

TCPServer

private TCPServer()
Creates a new TCPServer instance.


TCPServer

public TCPServer(int port)
Set up the internal state. Actual startup requires that the instantiating code call the start() method.

Parameters:
port - TCP/IP port for communication with the client.

TCPServer

public TCPServer(int port,
                 boolean isSSL)
Creates a new TCPServer instance.

Parameters:
port - an int value
isSSL - a boolean value

TCPServer

public TCPServer(int port,
                 int maxServers)
Creates a new TCPServer instance. Set up the internal state. Actual startup requires that the instantiating code call the start() method.

Parameters:
port - an int value
maxServers - an int value

TCPServer

public TCPServer(int port,
                 int maxServers,
                 boolean isSSL)
Creates a new TCPServer instance.

Parameters:
port - an int value
maxServers - an int value
isSSL - a boolean value

TCPServer

public TCPServer(int port,
                 int maxServers,
                 long connTO)
Creates a new TCPServer instance. Set up the internal state. Actual startup requires that the instantiating code call the start() method.

Parameters:
port - an int value
maxServers - an int value
connTO - over-ride the default connection TimeOut.

TCPServer

public TCPServer(int port,
                 int maxServers,
                 long connTO,
                 boolean isSSL)
Creates a new TCPServer instance.

Parameters:
port - an int value
maxServers - an int value
connTO - a long value
isSSL - a boolean value
Method Detail

runServer

public void runServer(Connection conn)
Create a new requestHandler thread passing the connection and start the thread. The thread is set to a daemon thread so if the parent thread exits, all the RequestHandler threads will as well.

May be over-ridden in the subclass to provide the server functionality when either single-threading or exceptional operation is required.

Parameters:
conn - a Connection value

start

public void start()
Spawn a thread if needed and open the server socket.


stop

public void stop()
Cleanup and shutdown.


finalize

protected void finalize()
Describe finalize method here.


run

public void run()
Main control loop of the thread, calls runServer to perform the actual server operations. Getting a connection is a blocking operation.

Specified by:
run in interface java.lang.Runnable

statsString

public java.lang.String statsString()
statsString - present the current state as a String.

Returns:
String representation of interface state.

isOnLine

public boolean isOnLine()
Return the current value of the onLine status.

Returns:
true if the server is online, false otherwise.

setOnLine

public void setOnLine(boolean v)
Set the value of the online status. Setting this to false will keep the server from accepting requests.

Parameters:
v - new value for the online status.

getMaxServers

public int getMaxServers()
Get the value of maxServers.

Returns:
value of maxServers.

setMaxServers

public void setMaxServers(int v)
Set the value of maxServers.

Parameters:
v - Value to assign to maxServers.

isIsSSL

public boolean isIsSSL()
Get the value of isSSL.

Returns:
value of isSSL.

setIsSSL

public void setIsSSL(boolean v)
Set the value of isSSL.

Parameters:
v - Value to assign to isSSL.


Copyright © 2001-2002 MileStone Solutions, Inc. All Rights Reserved.