QJCC homepage

biz.chitec.quarterback.gjsa.server
Class LoggerCenter

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.server.LoggerCenter

public class LoggerCenter
extends java.lang.Object

Global handler for free-floating-channel-assignments. Instantiated once per GJSA server. Gets information about all receivable loggers. Server threads can then attach themselves to those loggers. The Mutex cares for multiple-executor-aware handling of these attachments. The attachment of a ServerThreadBase to a Logger is only removed if all executors are removed that have asked for the attachment. Main data storage is the threadbases map. It contains a map for each registered ServerThreadBase (identified by its number). The per-ServerThreadBase maps contain the loggers as keys and a Set as value. The Set contains a list of all CommandExecutors which have attached themselved to this very logger. If all CommandExecutors detach from a logger, the ServerThreadBase is deregistered from it. Same happens if the ServerThreadBase itself closes. The main map, threadbases is synchronized. E.g. it can be accessed by all the handling threads at the same time. As every ServerThreadBase runs in its own thread (and either itself or any cleanup task is running at the same time), the per-ServerThreadBase maps and Sets do not need to be synchronized.

Version:
$Id: 39b52f440817daf48a6a5417169b24c4ea905d7a $
Author:
cantamen/Dirk Hillbrecht 2004

Field Summary
private  java.util.Map loggers
           
 
Constructor Summary
LoggerCenter(GJSAServer myserverx)
           
 
Method Summary
 Logger getLogger(java.lang.String name)
          Returns a stored logger.
 void putLogger(java.lang.String name, Logger logger)
          Adds a new logger.
 boolean registerExecutor(java.lang.String loggername, CommandExecutor exec)
          Register an executor unconditionally and without transaction number The executor's ServerThreadBase is registered without conditions to the Logger.
 boolean registerExecutor(java.lang.String loggername, CommandExecutor exec, boolean updatereceiver)
          Register an executor without transaction number or logical expression, but with the possibility to set update recevier flag.
 boolean registerExecutor(java.lang.String loggername, CommandExecutor exec, int transactionnumber)
          Register an executor without logical expression
 boolean registerExecutor(java.lang.String loggername, LogicExpr lex, CommandExecutor exec)
          Register an executor without transaction number
protected  boolean registerExecutor(java.lang.String loggername, LogicExpr lex, CommandExecutor exec, int transactionnumber, boolean updatereceiver)
          Register an executor for logging.
 void removeLogger(java.lang.String name)
          Removes a logger.
 boolean unregisterExecutor(java.lang.String loggername, CommandExecutor exec)
          Unregister an executor from listening to a logger.
 void unregisterServerThreadBase(ServerThreadBase stb)
          Unregisters a ServerThreadBase directly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loggers

private java.util.Map loggers
Constructor Detail

LoggerCenter

public LoggerCenter(GJSAServer myserverx)
Method Detail

putLogger

public void putLogger(java.lang.String name,
                      Logger logger)
Adds a new logger. As loggers are a system-wide instance, they should only be added while server initialisation. Therefore, the map is unsynchronized.

Parameters:
name - Name of the logger
logger - The logger object

getLogger

public Logger getLogger(java.lang.String name)
Returns a stored logger.


removeLogger

public void removeLogger(java.lang.String name)
Removes a logger.


registerExecutor

protected boolean registerExecutor(java.lang.String loggername,
                                   LogicExpr lex,
                                   CommandExecutor exec,
                                   int transactionnumber,
                                   boolean updatereceiver)
Register an executor for logging. The ServerThreadBase for this executor is registered as receiver to the logger which is given by its name. The executor is stored as "interested". If the ServerThreadBase is already registered, nothing happens. Note: As logical expression, only the first given expression is actually stored. Therefore, registrating CommandExecutors of the same ServerThreadBase with different logical expressions might produce confusing results. Also, the transactionnumber and the updatereceiver request is only evaluated for the first registered logger.

Parameters:
loggername - Name of a logger to register at
lex - logical expression to register as
exec - CommandExecutor which has requested registration
transactionnumber - last received number for this receiver
updatereceiver - requests update of receiver if logger is UpdateableLogger
Returns:
true if ServerThreadBase was really added, false if it was already registered

registerExecutor

public boolean registerExecutor(java.lang.String loggername,
                                CommandExecutor exec,
                                boolean updatereceiver)
Register an executor without transaction number or logical expression, but with the possibility to set update recevier flag.

Parameters:
loggername - Name of a logger to register at
exec - CommandExecutor which has requested registration
updatereceiver - requests update of receiver if logger is UpdateableLogger
Returns:
true if ServerThreadBase was really added, false if it was already registered

registerExecutor

public boolean registerExecutor(java.lang.String loggername,
                                LogicExpr lex,
                                CommandExecutor exec)
Register an executor without transaction number

Parameters:
loggername - Name of a logger to register at
lex - logical expression to register as
exec - CommandExecutor which has requested registration
Returns:
true if ServerThreadBase was really added, false if it was already registered

registerExecutor

public boolean registerExecutor(java.lang.String loggername,
                                CommandExecutor exec,
                                int transactionnumber)
Register an executor without logical expression

Parameters:
loggername - Name of a logger to register at
exec - CommandExecutor which has requested registration
transactionnumber - last received number for this receiver
Returns:
true if ServerThreadBase was really added, false if it was already registered

registerExecutor

public boolean registerExecutor(java.lang.String loggername,
                                CommandExecutor exec)
Register an executor unconditionally and without transaction number The executor's ServerThreadBase is registered without conditions to the Logger.

Parameters:
loggername - Name of a logger to register with
exec - CommandExecutor requesting the registration
Returns:
true if ServerThreadBase was really added, false if it was already registered

unregisterExecutor

public boolean unregisterExecutor(java.lang.String loggername,
                                  CommandExecutor exec)
Unregister an executor from listening to a logger. The given executor is removed from the interested executors' list. If the list is empty afterwards, the ServerThreadBase of the executor is unregistered from the logger itself and will therefore not receive any more items.

Parameters:
loggername - Logger to remove from
exec - Executor asking for removal
Returns:
true if executor is not among receivers any more, false if someone else is still listening

unregisterServerThreadBase

public void unregisterServerThreadBase(ServerThreadBase stb)
Unregisters a ServerThreadBase directly. If the given ServerThreadBase has been registered to any loggers, it is removed from them. After that, it is also removed from the internal storages. This method should be called if a ServerThreadBase is about to be closed.

Parameters:
stb -

QJCC homepage