amber.server.manager.connection
Class ConnectionManager

java.lang.Object
  |
  +--amber.server.manager.connection.ConnectionManager

public class ConnectionManager
extends java.lang.Object

Management class which looks after the requirements of incoming connections. Connections come into the listener threads and are assigned to the respective managers for processing.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
Core

Field Summary
protected  AmberInputStream dataDecoder
          The data decoding data stream that is used by all components to send information.
protected  AmberOutputStream dataEncoder
           
protected  java.io.ByteArrayOutputStream encoderBytes
          The data encoding data stream that is used by all components to send information.
 
Constructor Summary
ConnectionManager(Core parentServer, int port, DatabaseManager manager, ConnectionPool connectionPool, PropertiesHandler properties, Log logFile)
          Initialising constructor for this manager.
 
Method Summary
protected  AmberInputStream createDataInput(Packet packet)
          This function creates a data input stream from the data in the packet.
protected  void createListenerThreads()
          This function starts the socket listener threads.
 ConnectionPool getConnectionPool()
          Returns the current connection pool for the amber server.
 DatabaseManager getDatabaseManager()
          Returns the current database manager.
protected  AmberInputStream getDataInput()
          This function returns the current data input stream.
 Log getLogger()
          This function returns the logging object.
 Core getParentServer()
          Returns the parent server object for this manager.
 PropertiesHandler getProperties()
          This function returns the properties handler.
 void handleNewConnection(java.net.Socket socket, Packet initPacket, int type)
          This function matches the incomimg packet to the corresponding page handler in the pendingPages variable.
 boolean isDatabaseAvailable()
          This function returns whether the database is available for use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataDecoder

protected AmberInputStream dataDecoder
The data decoding data stream that is used by all components to send information. THIS MUST BE USED FOR DECODING INFORMATION FROM THE SERVER!! See the associated accessor/creator functions

encoderBytes

protected java.io.ByteArrayOutputStream encoderBytes
The data encoding data stream that is used by all components to send information. THIS MUST BE USED FOR ENCODING INFORMATION TO THE CLIENT!! Owing to the way Java works it is not meaningful to have a corresponding input object statically created.

dataEncoder

protected AmberOutputStream dataEncoder
Constructor Detail

ConnectionManager

public ConnectionManager(Core parentServer,
                         int port,
                         DatabaseManager manager,
                         ConnectionPool connectionPool,
                         PropertiesHandler properties,
                         Log logFile)
Initialising constructor for this manager.
Method Detail

handleNewConnection

public void handleNewConnection(java.net.Socket socket,
                                Packet initPacket,
                                int type)
                         throws java.io.IOException,
                                ApplicationException
This function matches the incomimg packet to the corresponding page handler in the pendingPages variable. A match is activated and placed in the activePages vector. If there is no match the link is dropped and the packet is ignored.
Parameters:
socket - Socket of the incoming connection.
initPacket - The Packet which is first sent by the page when the connection is opened.
type - The type of connection that is attempting to match the packet. This matches the constants in ListenerThread.
Throws:
java.io.IOException - containing decoding errors.
ApplicationException - containing application errors.

isDatabaseAvailable

public boolean isDatabaseAvailable()
This function returns whether the database is available for use.
Returns:
true should the database manager exist.

getDatabaseManager

public DatabaseManager getDatabaseManager()
Returns the current database manager.
Returns:
DatabaseManager for the server.

getConnectionPool

public ConnectionPool getConnectionPool()
Returns the current connection pool for the amber server.
Returns:
ConnectionPool pointing to the database used by the server itself.

getParentServer

public Core getParentServer()
Returns the parent server object for this manager.
Returns:
Core server object.

getLogger

public Log getLogger()
This function returns the logging object.
Returns:
Log object which is the primary server logging object.

getProperties

public PropertiesHandler getProperties()
This function returns the properties handler.
Returns:
PropertiesHandler object which contains the properties for the server.

createDataInput

protected AmberInputStream createDataInput(Packet packet)
This function creates a data input stream from the data in the packet.
Parameters:
packet - Packet containing the data to decode.
Returns:
AmberInputStream object for the corresponding data.

getDataInput

protected AmberInputStream getDataInput()
This function returns the current data input stream.
Returns:
AmberInputStream object for the current packet data.

createListenerThreads

protected void createListenerThreads()
This function starts the socket listener threads.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.