org.w3c.jigsaw.daemon
Class ServerHandlerManager

java.lang.Object
  extended by org.w3c.jigsaw.daemon.ServerHandlerManager

public class ServerHandlerManager
extends java.lang.Object

A ServerHandlerManager instance manages a set of ServerHandler.


Field Summary
static java.lang.String CLASS_P
          The server handler property class suffix.
static java.lang.String CLONES_P
          The server handler property clones prefix.
protected  java.lang.String[] commandLine
          Command line options that were provided at launch time.
protected  java.util.Hashtable handlers
          The list of running server handlers.
protected static java.lang.String HANDLERS_P
          The property containing the servers to be launched at startup time.
protected static ServerHandlerManager manager
          The Application-Wide server manager.
protected  DaemonProperties props
          The server handler manager property list.
static java.lang.String SERVER_GROUP_P
           
static java.lang.String SERVER_USER_P
           
 
Constructor Summary
ServerHandlerManager(java.lang.String[] args, java.io.File config, java.util.Properties p)
          Create and initialize a fresh server handler manager.
 
Method Summary
 java.util.Enumeration enumerateServerHandlers()
          Enumerate all the server handler manager's identifiers.
protected  void error(java.lang.String msg)
          Emit a non-fatal error.
protected  void fatal(java.lang.String msg)
          Emit a fatal error.
protected  void fixProperties(java.util.Properties p)
          For subclasses only.
 java.lang.String[] getCommandLine()
          Get the command line options that were provided at launch time.
protected  void launchServerHandler(java.lang.String id, DaemonProperties props)
          Launch a new server handler.
 ServerHandler lookupServerHandler(java.lang.String id)
          Lookup the server handler having the given identifier.
static void main(java.lang.String[] args)
           
 void removeServerHandler(ServerHandler server)
          Remove a server handler from this manager
 void shutdown()
          Shutdown this server handler manager.
 void unixStuff()
          Do some UNIX specific initialization.
static void usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HANDLERS_P

protected static final java.lang.String HANDLERS_P
The property containing the servers to be launched at startup time. This property is a | separated list of server identifiers. Declaring a server to this list requires that either:

See Also:
Constant Field Values

CLASS_P

public static final java.lang.String CLASS_P
The server handler property class suffix.

See Also:
Constant Field Values

CLONES_P

public static final java.lang.String CLONES_P
The server handler property clones prefix.

See Also:
Constant Field Values

SERVER_USER_P

public static final java.lang.String SERVER_USER_P
See Also:
Constant Field Values

SERVER_GROUP_P

public static final java.lang.String SERVER_GROUP_P
See Also:
Constant Field Values

manager

protected static ServerHandlerManager manager
The Application-Wide server manager.


handlers

protected java.util.Hashtable handlers
The list of running server handlers.


props

protected DaemonProperties props
The server handler manager property list.


commandLine

protected java.lang.String[] commandLine
Command line options that were provided at launch time.

Constructor Detail

ServerHandlerManager

public ServerHandlerManager(java.lang.String[] args,
                            java.io.File config,
                            java.util.Properties p)
Create and initialize a fresh server handler manager. Each server handler declared in the properties is launched in turn. If no server handlers is declared, or if none of them is initializable the server manager is not created and a RuntimeException is thrown, otherwise, if at least one server handler was initialized, the server manager emits appropriate error messages to the error stream for each of the server handlers whose launch failed.

Parameters:
props - The properties this manager should be initialized from.
Throws:
java.lang.RuntimeException - If no server handlers was declared through the properties.
Method Detail

error

protected void error(java.lang.String msg)
Emit a non-fatal error.

Parameters:
msg - The message to emit.

fatal

protected void fatal(java.lang.String msg)
Emit a fatal error. This will abort the whole process !

Parameters:
msg - The fata error message.

getCommandLine

public java.lang.String[] getCommandLine()
Get the command line options that were provided at launch time.

Returns:
A String array instance.

fixProperties

protected void fixProperties(java.util.Properties p)
For subclasses only. Used to update properties at runtime. This method is called by launchServerHandler(String id, DaemonProperties props).

Parameters:
p - the ServerHandlerManager properties.
See Also:
launchServerHandler

launchServerHandler

protected void launchServerHandler(java.lang.String id,
                                   DaemonProperties props)
Launch a new server handler. This method tries to launch a new server handler. If launching succeeds, it returns happily, otherwise, it emits an error message to the standard error stream.

Parameters:
identifier - The identifier of the server handler to be launched.
props - The properties from which the server handler should initialize itself.

lookupServerHandler

public ServerHandler lookupServerHandler(java.lang.String id)
Lookup the server handler having the given identifier.

Parameters:
id - The identifier of the server handler to look for.
Returns:
A ServerHandler instance, or null if undefined.

enumerateServerHandlers

public java.util.Enumeration enumerateServerHandlers()
Enumerate all the server handler manager's identifiers.

Returns:
An enumeration of String.

removeServerHandler

public void removeServerHandler(ServerHandler server)
Remove a server handler from this manager

Parameters:
server, - the Server Handler to remove

shutdown

public void shutdown()
Shutdown this server handler manager. This method will call the shutdown method of all the running servers stopping the manager.

This server handler clones are considered shutdown too.


unixStuff

public void unixStuff()
Do some UNIX specific initialization. THis method exists straight if it cannot succeed !


usage

public static void usage()

main

public static void main(java.lang.String[] args)