amber.server.manager.application
Class ApplicationController

java.lang.Object
  |
  +--amber.server.manager.application.ApplicationController
All Implemented Interfaces:
TimerInterface

public class ApplicationController
extends java.lang.Object
implements TimerInterface

This class is responsible for managing new application connections to the server. The class can have multiple different profiles of connections which reflect the type of connection ie. normal, secure, administration. The Core manager instantiates one controller for each type of connection and passes the connection information to the correct controller.

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

Field Summary
 long MaxInactiveInterval
          The amount of time which an application can be held inactive before final termination.
 long TimerInterval
          The timer interval for this controller.
 
Constructor Summary
ApplicationController(ApplicationManager parentServer, int type, DatabaseManager manager, ConnectionPool connectionPool, java.lang.String tableName, PropertiesHandler properties, Log logFile)
          Main constructor for the application controller.
 
Method Summary
 void addActiveConnection(ServerConnectionInfo handler)
          This function adds the input ServerConnectionInfo into the list of active connections.
 void addApplicationHandler(ServerConnectionInfo handler)
          This function adds the specified ServerConnectionInfo to the manager.
 void addToCache(ServerConnectionInfo info)
          This function adds the ServerConnection information to the cache.
 ServerConnectionInfo checkLicense(int pageId, int pageSubId)
          Checks license conditions.
protected  ServerConnectionInfo createConnectionFromCache(int pageId, int pageSubId)
          Checks the system available handlers to determine if there is a matching ApplicationHandler.
protected  void createHandler(ServerConnectionInfo info, int pageId, int pageSubId)
          Actually creates a handler for the specified serverConnectionInfo.
protected  ServerConnectionInfo findDbHandler(int pageId, int pageSubId)
          Checks the database handlers to determine if there is a matching ApplicationHandler.
 ServerConnectionInfo findHandler(int pageId, int pageSubId)
          Checks the system available handlers to determine if there is a matching ApplicationHandler.
 ServerConnectionInfo findInactiveHandler(java.lang.String sessionId)
          Checks the system available inactive handlers to determine if there is a matching ApplicationHandler.
 void flushCache()
          This function flushes the cache of all values.
 void flushCacheEntry(int pageId, int pageSubId)
          Flushes the specified entry in the cache.
 java.util.Vector getActiveApplicationHandlers()
          This returns a Vector of all active ApplicationHandlers in the manager.
 java.util.Vector getConnectionInfoCache()
          This function returns the current cache of connection info objects.
 java.util.Vector getInactiveApplicationHandlers()
          This returns a Vector of all inactive ApplicationHandlers in the manager.
 Log getLogger()
          This function returns the logging object.
 java.util.Vector getPendingApplicationHandlers()
          This returns a Vector of all pending ApplicationHandlers in the manager.
 ServerConnectionInfo locateInCache(int pageId, int pageSubId)
          Checks the system available handlers to determine if there is a matching ApplicationHandler.
 void reactivateConnection(ServerConnectionInfo handler)
          This function takes the specified ServerConnectionInfo from the list of inactive connections and places it back on the list of active connections.
 void removeAllPendingApplicationHandlers()
          This function removes all pending ApplicationHandlers in the manager.
 void removeApplicationHandler(ApplicationHandler pageHandler, boolean callShutDown)
          This function removes the specified ApplicationHandler from the manager.
 void removeApplicationHandler(int pageId, int pageSubId)
          This function removes the specified ApplicationHandler from the manager.
protected  void removeApplicationHandler(java.util.Vector pages, ApplicationHandler handler, boolean callShutDown)
          This function removes the specified ApplicationHandler from the page vector.
protected  void removeApplicationHandler(java.util.Vector pages, int pageId, int pageSubId)
          This function removes the specified ApplicationHandler from the manager.
 void removeCacheApplication(int pageId, int pageSubId)
          This function removes the specified entry in the cache.
 void setApplicationInactive(ApplicationHandler handler)
          This function tells the controller to set the specified ApplicationHandler as inactive.
 void timeEventOccurred()
          This function is called by the main timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TimerInterval

public final long TimerInterval
The timer interval for this controller.

MaxInactiveInterval

public final long MaxInactiveInterval
The amount of time which an application can be held inactive before final termination.
Constructor Detail

ApplicationController

public ApplicationController(ApplicationManager parentServer,
                             int type,
                             DatabaseManager manager,
                             ConnectionPool connectionPool,
                             java.lang.String tableName,
                             PropertiesHandler properties,
                             Log logFile)
Main constructor for the application controller.
Parameters:
parentServer - ApplicationManager which is handling all types of applications.
type - int type of connection that this application controller manages. These connection values match the values in ListenerThread.
manager - DatabaseManager which can be used to perform database queries.
connectionPool - ConnectionPool pointing to the Amber database.
tableName - String containing the table to query to match the application to.
properties - PropertiesHandler which contains the properties for the main Amber Server.
logFile - Log object to log errors to.
See Also:
ListenerThread
Method Detail

checkLicense

public ServerConnectionInfo checkLicense(int pageId,
                                         int pageSubId)
                                  throws java.io.IOException
Checks license conditions. If they are violated a LicenseViolatedApplicationHandler is returned in the ServerConnectionInfo. int pageId. Application identifying primary ID number. int pageSubId. Application identifying secondary ID number.
Returns:
ServerConnectionInfo containing the required application details or null if there is no match.

addApplicationHandler

public void addApplicationHandler(ServerConnectionInfo handler)
                           throws ManagerException
This function adds the specified ServerConnectionInfo to the manager.
Parameters:
handler - ServerConnectionInfo handle of the page to add.
Throws:
ManagerException - with any errors.

addActiveConnection

public void addActiveConnection(ServerConnectionInfo handler)
This function adds the input ServerConnectionInfo into the list of active connections.
Parameters:
handler - ServerConnectionInfo containing the details on the new connection to add. int type. The type of connection to look for a corresponding application for. The types must match the constants in ListenerThread. connection.

reactivateConnection

public void reactivateConnection(ServerConnectionInfo handler)
This function takes the specified ServerConnectionInfo from the list of inactive connections and places it back on the list of active connections.
Parameters:
handler - ServerConnectionInfo containing the details on the connection to reactivate. int type. The type of connection to look for a corresponding application for. The types must match the constants in ListenerThread. connection.

removeApplicationHandler

public void removeApplicationHandler(ApplicationHandler pageHandler,
                                     boolean callShutDown)
This function removes the specified ApplicationHandler from the manager. This function will not delete from the database as there is no instantiated ApplicationHandler
Parameters:
pageHandler - ApplicationHandler handle of the page to remove.
callShutDown - boolean true if the shut down function on the ApplicationHandler is to be called first.

removeApplicationHandler

public void removeApplicationHandler(int pageId,
                                     int pageSubId)
This function removes the specified ApplicationHandler from the manager.
Parameters:
pageId - int containing the Page identifier of the page to terminate.
pageSubId - int containing the Page Sub identifier of the page to terminate.

removeApplicationHandler

protected void removeApplicationHandler(java.util.Vector pages,
                                        int pageId,
                                        int pageSubId)
This function removes the specified ApplicationHandler from the manager.
Parameters:
pages - Vector containing the pages to search for the application.
pageId - int containing the Page identifier of the page to terminate.
pageSubId - int containing the Page Sub identifier of the page to terminate.

removeApplicationHandler

protected void removeApplicationHandler(java.util.Vector pages,
                                        ApplicationHandler handler,
                                        boolean callShutDown)
This function removes the specified ApplicationHandler from the page vector. This function will not delete from the database as there is no instantiated ApplicationHandler
Parameters:
pages - Vector containing the pages to search for the application.
pageHandler - ApplicationHandler handle of the page to remove.
callShutDown - boolean true if the shut down function on the ApplicationHandler is to be called first.

setApplicationInactive

public void setApplicationInactive(ApplicationHandler handler)
This function tells the controller to set the specified ApplicationHandler as inactive. Should the client not reconnect the server will clean up the application after a delay specified in the Controller.
Parameters:
handler - ApplicationHandler handle of the page to set inactive.

getActiveApplicationHandlers

public java.util.Vector getActiveApplicationHandlers()
This returns a Vector of all active ApplicationHandlers in the manager.
Returns:
Vector of amber.type.server.ServerConnectionInfo containing the required information.

getInactiveApplicationHandlers

public java.util.Vector getInactiveApplicationHandlers()
This returns a Vector of all inactive ApplicationHandlers in the manager.
Returns:
Vector of amber.type.server.ServerConnectionInfo containing the required information.

removeAllPendingApplicationHandlers

public void removeAllPendingApplicationHandlers()
This function removes all pending ApplicationHandlers in the manager.

findDbHandler

protected ServerConnectionInfo findDbHandler(int pageId,
                                             int pageSubId)
Checks the database handlers to determine if there is a matching ApplicationHandler. int pageId. Application identifying primary ID number. int pageSubId. Application identifying secondary ID number.
Returns:
ServerConnectionInfo containing the required application details or null if there is no match.

createHandler

protected void createHandler(ServerConnectionInfo info,
                             int pageId,
                             int pageSubId)
                      throws java.lang.ClassNotFoundException,
                             java.lang.IllegalAccessException,
                             java.lang.InstantiationException
Actually creates a handler for the specified serverConnectionInfo.
Parameters:
info - The ServerConnectionInfo for this connection.
pageId - int page ID for this connection.
pageSubId - int page sub ID for this connection.
Throws:
java.lang.ClassNotFoundException - if the class does not exist.
java.lang.IllegalAccessException - if the class cannot be accessed (scope).
java.lang.ClassNotFoundException - if the class cannot be created.

findHandler

public ServerConnectionInfo findHandler(int pageId,
                                        int pageSubId)
Checks the system available handlers to determine if there is a matching ApplicationHandler. int pageId. Application identifying primary ID number. int pageSubId. Application identifying secondary ID number.
Returns:
ServerConnectionInfo containing the required application details or null if there is no match.

createConnectionFromCache

protected ServerConnectionInfo createConnectionFromCache(int pageId,
                                                         int pageSubId)
Checks the system available handlers to determine if there is a matching ApplicationHandler. It looks only in the internal cache of connections. Once the connection is located then a new connection info object is created to hold the new connection. int pageId. Application identifying primary ID number. int pageSubId. Application identifying secondary ID number.
Returns:
ServerConnectionInfo containing the new application details or null if there is no match.

locateInCache

public ServerConnectionInfo locateInCache(int pageId,
                                          int pageSubId)
Checks the system available handlers to determine if there is a matching ApplicationHandler. It looks only in the internal cache of connections. int pageId. Application identifying primary ID number. int pageSubId. Application identifying secondary ID number.
Returns:
ServerConnectionInfo containing the required application details or null if there is no match.

removeCacheApplication

public void removeCacheApplication(int pageId,
                                   int pageSubId)
This function removes the specified entry in the cache. int pageId. Application identifying primary ID number. int pageSubId. Application identifying secondary ID number.

addToCache

public void addToCache(ServerConnectionInfo info)
This function adds the ServerConnection information to the cache. It duplicates the server connection data.
Parameters:
info - ServerConnectionInfo to add to the cache.

getConnectionInfoCache

public java.util.Vector getConnectionInfoCache()
This function returns the current cache of connection info objects.
Returns:
Vector containing the cache.

flushCache

public void flushCache()
This function flushes the cache of all values.

flushCacheEntry

public void flushCacheEntry(int pageId,
                            int pageSubId)
Flushes the specified entry in the cache. int pageId. Application identifying primary ID number. int pageSubId. Application identifying secondary ID number.

findInactiveHandler

public ServerConnectionInfo findInactiveHandler(java.lang.String sessionId)
Checks the system available inactive handlers to determine if there is a matching ApplicationHandler. String sessionId. The session ID the application was started with. This should be unique for an application.
Returns:
ServerConnectionInfo containing the required application details or null if there is no match.

getPendingApplicationHandlers

public java.util.Vector getPendingApplicationHandlers()
This returns a Vector of all pending ApplicationHandlers in the manager. This includes the pending ApplicationHandlers in the database or in the RMI list.
Returns:
Vector of amber.type.server.ServerConnectionInfo containing the required information.

getLogger

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

timeEventOccurred

public void timeEventOccurred()
This function is called by the main timer. It is used to perform internal housekeeping functions.
Specified by:
timeEventOccurred in interface TimerInterface


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.