amber.server
Class Listener

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--amber.server.Listener
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
ListenerThread

public class Listener
extends java.lang.Thread

Thread to deal with the incoming connections of login packets. This thread waits for incomimg connections and adds them to the receiver for processing.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
ConnectionManager, LoginThread

Field Summary
static int AdministrationConnection
           
static java.lang.String[] connectionNames
          String array containing strings which match the connection values.
static int DefaultNumberPendingConnections
          The default number of pending connections the listener will accept.
protected  java.net.ServerSocket listener
          Primary Server Socket which waits for incoming connections.
protected  Log loggingFile
          The logging system to use for error messages.
static int NormalConnection
          This constant defines one category of incoming connections.
protected  int numberPendingConnections
          This contains the number of pending connections that the listener will accept.
protected  boolean operating
          Internal flag which indicates whether the thread is operating.
protected  int portNumber
          The port number to listen on.
protected  ConnectionReceiver receiver
          The thread concerned with handling incoming socket connections.
static int SecureConnection
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Listener(ConnectionReceiver receiver, int portNumber, Log loggingFile, java.lang.String threadName, int type)
          Construct the thread, with it's parent class so it may pass back messages.
Listener(ConnectionReceiver receiver, int portNumber, Log loggingFile, java.lang.String threadName, int type, int pendingAllowed)
          Construct the thread, with it's parent class so it may pass back messages.
 
Method Summary
 int getType()
          Returns the type of listener this is.
static java.lang.String getTypeString(int type)
          Returns a string corresponding to the type value.
 void run()
           
 void setType(int type)
          Sets the type of listener this is.
 void terminate()
          This function causes the flag to be set terminating this thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NormalConnection

public static final int NormalConnection
This constant defines one category of incoming connections.

SecureConnection

public static final int SecureConnection

AdministrationConnection

public static final int AdministrationConnection

DefaultNumberPendingConnections

public static final int DefaultNumberPendingConnections
The default number of pending connections the listener will accept.

connectionNames

public static final java.lang.String[] connectionNames
String array containing strings which match the connection values.

operating

protected boolean operating
Internal flag which indicates whether the thread is operating.

receiver

protected ConnectionReceiver receiver
The thread concerned with handling incoming socket connections.

portNumber

protected int portNumber
The port number to listen on.

loggingFile

protected Log loggingFile
The logging system to use for error messages.

listener

protected java.net.ServerSocket listener
Primary Server Socket which waits for incoming connections.

numberPendingConnections

protected int numberPendingConnections
This contains the number of pending connections that the listener will accept.
Constructor Detail

Listener

public Listener(ConnectionReceiver receiver,
                int portNumber,
                Log loggingFile,
                java.lang.String threadName,
                int type)
         throws ManagerException
Construct the thread, with it's parent class so it may pass back messages.
Parameters:
receiver - ConnectionReceiver which will get the new connection.
portNumber - int containing the port number to listen on.
loggingFile - Log object to log messages on.
threadName - String containing the name of this thread.
type - int containing the type of listener this is. This matches the constants in this class.
certificate - RSAKey containing the encryption certificate. This is required for secure connections.
Throws:
ManagerException - should there be an error initialising the thread.

Listener

public Listener(ConnectionReceiver receiver,
                int portNumber,
                Log loggingFile,
                java.lang.String threadName,
                int type,
                int pendingAllowed)
         throws ManagerException
Construct the thread, with it's parent class so it may pass back messages.
Parameters:
receiver - ConnectionReceiver which will get the new connection.
portNumber - int containing the port number to listen on.
loggingFile - Log object to log messages on.
threadName - String containing the name of this thread.
type - int containing the type of listener this is. This matches the constants in this class.
certificate - RSAKey containing the encryption certificate. This is required for secure connections.
pendingAllowed - int number of pending connections the listener will allow before refusing connections.
Throws:
ManagerException - should there be an error initialising the thread.
Method Detail

terminate

public void terminate()
This function causes the flag to be set terminating this thread.

run

public void run()
Overrides:
run in class java.lang.Thread

setType

public void setType(int type)
Sets the type of listener this is.
Parameters:
type - int type of listener. This must match the type constants specified in this class.

getType

public int getType()
Returns the type of listener this is.
Returns:
int type of listener. This must match the type constants specified in this class.

getTypeString

public static java.lang.String getTypeString(int type)
Returns a string corresponding to the type value.
Parameters:
type - int type of listener. This must match the type constants specified in this class.
Returns:
String containing the type of connection.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.