amber.server.manager
Class Core

java.lang.Object
  |
  +--amber.server.manager.Core
All Implemented Interfaces:
CoreInterface

public class Core
extends java.lang.Object
implements CoreInterface

Central controlling class which handles the complete requirements for the server system. It initiates and controls the various server components required to make the server function.

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

Field Summary
protected  AmberInputStream dataDecoder
          The data decoding data stream that is used by all components to send information.
protected  AmberOutputStream dataEncoder
           
static int DefaultExpirationTime
          The default expiration time is infinity (sec)
static java.lang.String DefaultLoggingFilename
          The logging file name
protected  java.io.ByteArrayOutputStream encoderBytes
          The data encoding data stream that is used by all components to send information.
protected  amber.server.manager.FlatFileApplicationDatabase normalPreCache
          Precache items for the connection server.
static int ServerPort
          The port the server listens on.
static int VersionNumber
          The absolute version number for the server.
 
Constructor Summary
Core(java.lang.String name, DatabaseManager manager, java.lang.String connectionPoolName, java.lang.String logFilename, int logLevel, int port, amber.utility.AmberLicenseKey licenseKey, PropertiesHandler properties)
          The complete constuctor for the Amber Server Implementation.
 
Method Summary
protected  java.lang.String convertRelativeToAbsoluteDirectory(java.lang.String directory)
          This function converts a relative directory into a corresponding absolute form.
protected  AmberInputStream createDataInput(Packet packet)
          This function creates a data input stream from the data in the packet.
 java.lang.String getAmberRoot()
          Returns the directory where the Amber server is currently running.
 ApplicationManager getApplicationManager()
          This function returns the application manager object responsible for handling the requirements of managing applications and their associated handlers.
 ConnectionManager getConnectionManager()
          This function returns the connection manager object responsible for handling incoming connections.
 ConnectionPool getConnectionPool()
          Returns the current connection pool for the amber server.
static Core getCore()
          This function returns the global instance of the core object.
 DatabaseManager getDatabaseManager()
          This function returns the database manager object responsible for handling incoming database connections.
protected  AmberInputStream getDataInput()
          This function returns the current data input stream.
 java.lang.String getDocumentRoot()
          Returns the directory of the web server's document root.
 amber.utility.AmberLicenseKey getLicenseKey()
          Returns the license key object.
static int getLicenseVersion()
          Returns the licence version of the server.
 Log getLogger()
          This function returns the logging object.
 ConnectionHandler getManager(int type)
          This function returns the manager object responsible for handling the requirements of the specified remote object type
 java.lang.String getNewSessionIdentifier()
          This function returns a unique session identifier.
 PropertiesHandler getProperties()
          Returns the system wide properties for this server.
 void handleNewConnection(java.net.Socket socket, Packet initPacket, int systemType, int type)
          This function matches the incomimg packet to the corresponding page handler in the pendingPages variable.
 boolean isDatabaseAvailable()
          This function returns whether the AmberPages database is active for this server.
protected  amber.server.manager.FlatFileApplicationDatabase loadCache(java.lang.String filename)
          Loads the specified connection cache file.
protected  boolean loadPreCacheConnections()
          Looks in the configuration to see if there are any precache files to load.
protected  HandlerManager processManagerString(java.lang.String managerString)
          This function creates all the additional managers specified in the properties file.
 void sendEmail(java.lang.String to, java.lang.String from, java.lang.String subject, java.lang.String body, java.lang.String smtpServer)
          This function sends a mail message to the specified user.
 void setLoggingLevel(int level)
          This function sets the level of logging in the server.
protected  void startManagers()
          This function starts the various managers required by the server to make the system function.
 void stopServer()
          This function stops the server remotely.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VersionNumber

public static final int VersionNumber
The absolute version number for the server. This is a monotonically increasing number and must match that transmitted by the client on connection.

ServerPort

public static final int ServerPort
The port the server listens on.

DefaultExpirationTime

public static final int DefaultExpirationTime
The default expiration time is infinity (sec)

DefaultLoggingFilename

public static final java.lang.String DefaultLoggingFilename
The logging file name

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

normalPreCache

protected amber.server.manager.FlatFileApplicationDatabase normalPreCache
Precache items for the connection server. These are for normal connections.
Constructor Detail

Core

public Core(java.lang.String name,
            DatabaseManager manager,
            java.lang.String connectionPoolName,
            java.lang.String logFilename,
            int logLevel,
            int port,
            amber.utility.AmberLicenseKey licenseKey,
            PropertiesHandler properties)
     throws ManagerException
The complete constuctor for the Amber Server Implementation.
Parameters:
name - String containing the name of the server when RMI registering this object.
manager - DatabaseManager which handles the database connections.
connectionPoolName - String containing the name of the database connection pool to use.
logFilename - String containing the name of the log file.
logLevel - int containing the log level to log.
port - int containing the port number to listen to for unsecure connections.
securePort - int containing the port number to listen to for unsecure connections.
adminPort - int containing the port number to listen to for administration connections.
properties - PropertiesHandler containing the system configuration properties.
Throws:
ManagerException - with other types of errors.
Method Detail

loadPreCacheConnections

protected boolean loadPreCacheConnections()
                                   throws ManagerException
Looks in the configuration to see if there are any precache files to load. If there are then the function loads them for the different connection types.
Returns:
true if there are precache items.
Throws:
ManagerException - should the loading fail.

loadCache

protected amber.server.manager.FlatFileApplicationDatabase loadCache(java.lang.String filename)
                                                              throws AmberException
Loads the specified connection cache file.
Parameters:
filename - String name of the file to load.
Returns:
FlatFileApplicationDatabase containing the application connections.
Throws:
AmberException - should the loading fail.

startManagers

protected void startManagers()
                      throws ManagerException
This function starts the various managers required by the server to make the system function.
Throws:
ManagerException - with other types of errors.

processManagerString

protected HandlerManager processManagerString(java.lang.String managerString)
                                       throws java.lang.ClassNotFoundException,
                                              java.lang.IllegalAccessException,
                                              java.lang.InstantiationException,
                                              ManagerException
This function creates all the additional managers specified in the properties file.
Throws:
ManagerException - with other types of errors.

handleNewConnection

public void handleNewConnection(java.net.Socket socket,
                                Packet initPacket,
                                int systemType,
                                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.
systemType - The type of remote system which is attempting to connect.
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.

stopServer

public void stopServer()
This function stops the server remotely.
Specified by:
stopServer in interface CoreInterface

setLoggingLevel

public void setLoggingLevel(int level)
                     throws ManagerException
This function sets the level of logging in the server.
Specified by:
setLoggingLevel in interface CoreInterface
Parameters:
level - int level to set the debugging to. This corresponds to values in the Log object.
Throws:
ManagerException - with any errors.

getLogger

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

isDatabaseAvailable

public boolean isDatabaseAvailable()
This function returns whether the AmberPages database is active for this server.
Returns:
boolean true if database is active.

sendEmail

public void sendEmail(java.lang.String to,
                      java.lang.String from,
                      java.lang.String subject,
                      java.lang.String body,
                      java.lang.String smtpServer)
This function sends a mail message to the specified user.
Specified by:
sendEmail in interface CoreInterface
Parameters:
to - String name of the recipient.
from - String name of the sender.
subject - String containing the subject of the e-mail.
body - String containing the body of the text mail message.
smtpServer - String containing the SMTP mail server address.

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.

getDatabaseManager

public DatabaseManager getDatabaseManager()
This function returns the database manager object responsible for handling incoming database connections.
Specified by:
getDatabaseManager in interface CoreInterface
Returns:
DatabaseManager which manages database connections.

getConnectionPool

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

getManager

public ConnectionHandler getManager(int type)
This function returns the manager object responsible for handling the requirements of the specified remote object type
Specified by:
getManager in interface CoreInterface
Returns:
ConnectionHandler which manages the remote objects.

getApplicationManager

public ApplicationManager getApplicationManager()
This function returns the application manager object responsible for handling the requirements of managing applications and their associated handlers.
Specified by:
getApplicationManager in interface CoreInterface
Returns:
ApplicationManager which manages the applications.

getConnectionManager

public ConnectionManager getConnectionManager()
This function returns the connection manager object responsible for handling incoming connections.
Specified by:
getConnectionManager in interface CoreInterface
Returns:
ConnectionManager which manages connections.

getCore

public static Core getCore()
This function returns the global instance of the core object. There should only ever be one.
Returns:
Core handle to the global core server object.

getNewSessionIdentifier

public java.lang.String getNewSessionIdentifier()
This function returns a unique session identifier. This information is used when reestablishing the connection correctly. during fail-over.
Specified by:
getNewSessionIdentifier in interface CoreInterface
Returns:
String containing the session identifier.

getProperties

public PropertiesHandler getProperties()
Returns the system wide properties for this server.
Returns:
PropertiesHandler containing the properties for the server.

getLicenseKey

public amber.utility.AmberLicenseKey getLicenseKey()
Returns the license key object.
Specified by:
getLicenseKey in interface CoreInterface
Returns:
AmberLicenseKey containing the current license conditions.

getAmberRoot

public java.lang.String getAmberRoot()
Returns the directory where the Amber server is currently running.
Specified by:
getAmberRoot in interface CoreInterface
Returns:
String containing the Amber server directory.

getDocumentRoot

public java.lang.String getDocumentRoot()
Returns the directory of the web server's document root.
Specified by:
getDocumentRoot in interface CoreInterface
Returns:
String containing the document root directory.

convertRelativeToAbsoluteDirectory

protected java.lang.String convertRelativeToAbsoluteDirectory(java.lang.String directory)
This function converts a relative directory into a corresponding absolute form. It will leave unchanged any directory which does not start with '.'. It will also convert a null or empty string into the current directory.
Parameters:
directory - String containing the directory to convert.
Returns:
converted absolute form of the directory.

getLicenseVersion

public static int getLicenseVersion()
Returns the licence version of the server.
Returns:
The licence version.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.