QJCC homepage

biz.chitec.quarterback.gjsa.server
Class BasicAdminExecutor

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.server.CommandExecutor
      extended bybiz.chitec.quarterback.gjsa.server.BasicAdminExecutor

public class BasicAdminExecutor
extends CommandExecutor

Administrative commands for setting global properties of a GJSA server. The commands in this executor serve for three purposes:

For the server configuration part, the executor allows the addition of indirections which can influence the data sent to client or received from there. Additionally, the executor features its own preprocessing including type check etc. to all configuration values.

Shutting down is controlled via the several EXIT commands. EXIT0 and EXIT1 end the server with status code 0 and 1 respectively. EXIT takes the status code number as parameter and can therefore end the server with any code. All these commands take two additional parameters: "prekilltime" and "message". If "prekilltime" is greater than zero. The server will not start the shutdown immediately but wait for the given amount of seconds before shutdown starts. During this time, WAITTOKILL messages will be sent to all connected clients every 10 seconds. If "message" is set, all clients will receive a KILLSTARTED message with the message and the prekilltime as parameter (as a Map with keys MESSAGE and TIMEOUT).

As long as a pending shutdown is in prekill state (e.g. "prekilltime" is still counting down), it can be CANCELLED with the STOPEXIT command. A KILLKILLED message will be sent to all clients.

Version:
$Id: 6583edb30b787f21fec891dbcc7e7a83cd5c9aa8 $
Author:
Dirk Hillbrecht 2000, chitec/Dirk Hillbrecht 2000-2003, cantamen/Dirk Hillbrecht 2003-2005. Distributed under the terms of the GNU LGPL.
See Also:
GJSAServer, Killer

Nested Class Summary
 class BasicAdminExecutor.HandlingIndirections
          Preprocessor for property changes Implementations of this class can influence the transmission of properties in both directions.
 
Field Summary
private  java.util.List changedprops
           
private  java.lang.String configloggername
           
private static EncryptionRulesSymbols ers
           
private  java.util.List indirlist
           
protected  Logger mess
           
protected  ChangeListener mycl
           
private  java.util.Map properties
           
 
Fields inherited from class biz.chitec.quarterback.gjsa.server.CommandExecutor
myserv, mythreadbase, rb
 
Constructor Summary
BasicAdminExecutor(ServerThreadBase thethreadbase)
          Create the executor with link to server only
BasicAdminExecutor(ServerThreadBase thethreadbase, java.lang.String configloggernamex)
          Create the executor with environment and name of server logger for configuration messages The logger will be used to send shutdown messages to all connected clients in case of shutdown commands
 
Method Summary
 void addChangeListener(ChangeListener cl)
          Add a change listener NOTE: The implementation is actually a fake.
protected  void addHandlingIndirections(BasicAdminExecutor.HandlingIndirections hi)
          Add an indirection handler which serves as kind of a preprocessor
static java.util.List createReturnableEncryptionRules(java.util.List x)
          Transform a list of encryption rules from numeric to symbolic encryption states.
 java.util.Map getCookedProperties()
          Get all properties with full preprocessing
 java.lang.Object getCookedProperty(java.lang.String key)
          Get one preprocessed property
protected  java.lang.Object getToClient(java.lang.String propname, java.lang.Object value)
          Prepare a configuration setting for sending to the client.
protected  java.lang.Object putFromClient(java.lang.String propname, java.lang.Object value)
          Prepare a configuration setting for inserting in the server.
 ServerReply query(ServerRequest sq)
           
private  void sendAdminMessage(java.lang.Object messagetype, java.util.Map params)
          Send a message to all connected clients The message can have an arbitrary type and any parameters.
 void setCookedProperty(java.lang.String key, java.lang.Object property)
          Set a properties value The property is checked against the property constraints for correct type.
protected  void storageInsertion(java.lang.String propname, java.lang.Object value)
          Inform all HandlingIndirections that a property is stored into the server.
protected  void storageSaving(java.util.List propnames)
          Inform all HandlingIndirections that the property storage is saved to disk.
 
Methods inherited from class biz.chitec.quarterback.gjsa.server.CommandExecutor
getServerThreadBase, leavingActions, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ers

private static EncryptionRulesSymbols ers

mess

protected Logger mess

mycl

protected ChangeListener mycl

indirlist

private java.util.List indirlist

changedprops

private java.util.List changedprops

properties

private java.util.Map properties

configloggername

private java.lang.String configloggername
Constructor Detail

BasicAdminExecutor

public BasicAdminExecutor(ServerThreadBase thethreadbase)
Create the executor with link to server only

Parameters:
thethreadbase - Connection environment

BasicAdminExecutor

public BasicAdminExecutor(ServerThreadBase thethreadbase,
                          java.lang.String configloggernamex)
Create the executor with environment and name of server logger for configuration messages The logger will be used to send shutdown messages to all connected clients in case of shutdown commands

Parameters:
thethreadbase - Connection environment
configloggernamex - Name of logger to send shutdown-related messages to
Method Detail

addHandlingIndirections

protected void addHandlingIndirections(BasicAdminExecutor.HandlingIndirections hi)
Add an indirection handler which serves as kind of a preprocessor


getToClient

protected java.lang.Object getToClient(java.lang.String propname,
                                       java.lang.Object value)
Prepare a configuration setting for sending to the client. Preparing means to pass the setting through all registered preprocessors (i.e. HandlingIndirection classes) so that they can somehow handle the value if they want to.

Parameters:
propname - Name of the property to send
value - Property's value before preprocessing
Returns:
Property's value after preprocessing

putFromClient

protected java.lang.Object putFromClient(java.lang.String propname,
                                         java.lang.Object value)
Prepare a configuration setting for inserting in the server. Preparing means to pass the setting through all registered preprocessors (i.e. HandlingIndirection classes) so that they can somehow handle the value if they want to.

Parameters:
propname - Name of the property to be inserted
value - Property's value before preprocessing (i.e. as the client sent it)
Returns:
Property's value after preprocessing (so to insert it into the server)

storageInsertion

protected void storageInsertion(java.lang.String propname,
                                java.lang.Object value)
Inform all HandlingIndirections that a property is stored into the server. The HandlingIndirections can take arbitrary actions on this event.

Parameters:
propname - Name of the property
value - Value that is stored into the server

storageSaving

protected void storageSaving(java.util.List propnames)
Inform all HandlingIndirections that the property storage is saved to disk. The HandlingIndirections can take arbitrary actions on this event.

Parameters:
propnames - Names of all changed properties

createReturnableEncryptionRules

public static java.util.List createReturnableEncryptionRules(java.util.List x)
Transform a list of encryption rules from numeric to symbolic encryption states. The given list is assumed to contain alternating values, every two being an "address-encryption rule" pair. The encryption rules are furthermore assumed to be expressed through their numeric value. These numeric values are changed into symbolic values using the appropriate symbol table.

Parameters:
x - List of encryption rules
Returns:
Same list with in-situ exchanged encryption rule definitions

getCookedProperties

public java.util.Map getCookedProperties()
Get all properties with full preprocessing

Returns:
Map with all properties, values are fully preprocessed

getCookedProperty

public java.lang.Object getCookedProperty(java.lang.String key)
Get one preprocessed property

Parameters:
key - Name of the property in question
Returns:
Preprocessed property value

setCookedProperty

public void setCookedProperty(java.lang.String key,
                              java.lang.Object property)
Set a properties value The property is checked against the property constraints for correct type.

Parameters:
key - Name of the property
property - New value

sendAdminMessage

private void sendAdminMessage(java.lang.Object messagetype,
                              java.util.Map params)
Send a message to all connected clients The message can have an arbitrary type and any parameters. So it is not necessarily something human-readable which is displayed on-screen. It is totally up to the client to handle the message appropriately.

Parameters:
messagetype - Type of the message
params - Parameters which make the message up

query

public ServerReply query(ServerRequest sq)
Overrides:
query in class CommandExecutor

addChangeListener

public void addChangeListener(ChangeListener cl)
Add a change listener NOTE: The implementation is actually a fake. There is no list managed but only one listener is stored.

Parameters:
cl - Listener to add/store

QJCC homepage