com.Prominic.jFTPd
Class GenericServer

java.lang.Object
  extended by com.Prominic.jFTPd.GenericServer
All Implemented Interfaces:
java.lang.Runnable

public class GenericServer
extends java.lang.Object
implements java.lang.Runnable

Interface for a generic server. This server has a connection handler wich will handle each connection.

Author:
Iulian

Field Summary
(package private)  boolean DEBUG
           
(package private)  ConnectionHandler handler
           
(package private)  int port
           
(package private)  java.net.ServerSocket ss
           
protected  java.util.Date startedOn
           
(package private)  boolean up
           
 
Constructor Summary
GenericServer(ConnectionHandler ch, int port)
          Creates a generic server on the given port and attaches a connection handler.
 
Method Summary
 java.util.Date getStartedOn()
          Gets the datetime when the Generic Server was created (datetime is set in the constructor).
 long getUptime()
          Gets the server uptime in seconds.
 boolean isListening()
          Checks if server is bound to the given port.
 void run()
          Starts the server and invoques the connection handler's doConnection method for each connection to the server socket.
 void setStartedOn(java.util.Date newStartedOn)
          Sets the new date for when the server was started.
 void stopServer()
          Stops the server (closes the server socket).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

final boolean DEBUG
See Also:
Constant Field Values

handler

ConnectionHandler handler

port

int port

ss

java.net.ServerSocket ss

up

boolean up

startedOn

protected java.util.Date startedOn
Constructor Detail

GenericServer

public GenericServer(ConnectionHandler ch,
                     int port)
Creates a generic server on the given port and attaches a connection handler. Creation date: (10-Dec-01 20:41:43)

Parameters:
ch - - connection handler
port - - port where the server socket will be created.
Method Detail

getStartedOn

public java.util.Date getStartedOn()
Gets the datetime when the Generic Server was created (datetime is set in the constructor).

Returns:
java.util.Date when the server was started.

getUptime

public long getUptime()
Gets the server uptime in seconds. Creation date: (10-Dec-01 20:43:36)

Returns:
long - server uptime in seconds.

isListening

public boolean isListening()
Checks if server is bound to the given port.

Returns:
true if a server socket was successfully created on the given port.

run

public void run()
Starts the server and invoques the connection handler's doConnection method for each connection to the server socket.

Specified by:
run in interface java.lang.Runnable

setStartedOn

public void setStartedOn(java.util.Date newStartedOn)
Sets the new date for when the server was started.

Parameters:
newStartedOn - - new datetime for when the server was started.

stopServer

public void stopServer()
Stops the server (closes the server socket).