Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.lutris.multiServer
Class MultiServer  view MultiServer download MultiServer.java

java.lang.Object
  extended bycom.lutris.multiServer.MultiServer

public class MultiServer
extends java.lang.Object

A stand-alone server. It starts and stops services like the ServletContainer.

At startup time a configuration file is read, and it describes what services to start. After this config file is read, and the server is set up, no further action is taken by the server. The thread that ran through main() exits. The Services must create threads, and they are responsible for receiving requests from the outside world and processing them.

Normally one of the Servlets will be an administration application. This admin app knows about this class, and so it knows how to talk to the current ConnectionMethods and Servlets. It may change the server setup on the fly. For example, it can create and add a new ConnectionMethod. Or it could add a new channel to an already existing ConnectionMethod. Or register a new Servlet. Or add a logging filter to a channel. Or monitor performance.

This class implements main(). It is meant to be run as a java application. Do not instantiate this class. Use the static variables.

The main() function will initialize and configure the global logging facility. The facility name is "MultiServer", and you may use any of the level names defined in the Logger class. One set of level names listed in the MultiServer config file have their output directed to the server log file. Another set of level names have their output directed to stderr. Text written to any other level name not mentioned in the server config file will be ignored.
Any class running in this virtual machine may write to the MultiServer log file, using the following code:

 import com.lutris.logging.*;
 LogChannel logChan = Logger.getCentralLogger().getChannel("Multiserver");
 int level = logChan.getLevel("ERROR");
 logChan.write(level, "An error occured: ....");
 


Field Summary
static java.lang.String ACTIVATION_KEY
           
private static com.lutris.util.Config config
           
private static com.lutris.util.ConfigFile configFile
           
private static java.lang.String configFileName
           
private static java.lang.String defaultConfigFileName
           
static java.lang.String LOG_FILE
           
static java.lang.String LOG_TO_FILE
           
static java.lang.String LOG_TO_STDERR
           
private static com.lutris.logging.LogChannel logChannel
           
private static long maxMemoryUsage
           
static java.lang.String SERIAL_NUMBER
           
static java.lang.String SERVER
           
private static java.util.Hashtable services
           
private static com.lutris.logging.StandardLogger standardLogger
           
 
Constructor Summary
private MultiServer()
          Don't ever create an instance of MultiServer.
 
Method Summary
static long currentMemoryUsage(boolean forceGC)
          This method is used to get the current value of the amount of memory being used by the virtual machine.
private static void fatalErr(java.lang.String msg)
           
private static void fatalErr(java.lang.String msg, java.lang.Throwable err)
           
static long getMaxMemoryUsage()
          This method if for getting the value that has been stored as highwater mark for memory usage by the virtual machine.
static Service getService(java.lang.String name)
          Get the named service.
static void main(java.lang.String[] argv)
          The entry point for the stand-alone server.
private static com.lutris.util.Config myGetSection(com.lutris.util.Config cfg, java.lang.String key)
           
private static com.lutris.util.Config myGetSection(com.lutris.util.Config cfg, java.lang.String key, boolean required)
           
private static java.lang.String myGetString(com.lutris.util.Config cfg, java.lang.String key)
           
private static java.lang.String myGetString(com.lutris.util.Config cfg, java.lang.String key, java.lang.String prefix)
           
private static java.lang.String myGetString(com.lutris.util.Config cfg, java.lang.String key, java.lang.String prefix, boolean required)
           
private static java.lang.String[] myGetStrings(com.lutris.util.Config t, java.lang.String key, java.lang.String prefix)
           
private static java.lang.String[] myGetStrings(com.lutris.util.Config t, java.lang.String key, java.lang.String prefix, boolean required)
           
private static void parseServerSection(com.lutris.util.Config server)
          Retrieve the server parameters from the config file and establish the logging facility.
private static void readConfigFile(java.lang.String filename)
          Parsing and implementing the config file.
static void resetMaxMemoryUsage()
          This method is used to reset the maxMemoryUsage back to zero.
static void setMaxMemoryUsage(long used)
          This method is used for setting the highwater mark for the amount of memory that the virtual machine has used.
static void shutdown()
          Shut down the server.
private static void start(java.lang.String[] argv)
          Do actual work of starting the multiserver.
private static java.lang.String trim(java.lang.String s)
           
static java.lang.String writeConfigFile(java.lang.String filename)
          This function examines the current state of the server and writes it out to the same config file that was read when the server was started up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxMemoryUsage

private static long maxMemoryUsage

standardLogger

private static com.lutris.logging.StandardLogger standardLogger

logChannel

private static com.lutris.logging.LogChannel logChannel

services

private static java.util.Hashtable services

defaultConfigFileName

private static final java.lang.String defaultConfigFileName
See Also:
Constant Field Values

configFileName

private static java.lang.String configFileName

configFile

private static com.lutris.util.ConfigFile configFile

config

private static com.lutris.util.Config config

SERVER

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

LOG_FILE

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

LOG_TO_FILE

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

LOG_TO_STDERR

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

SERIAL_NUMBER

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

ACTIVATION_KEY

public static final java.lang.String ACTIVATION_KEY
See Also:
Constant Field Values
Constructor Detail

MultiServer

private MultiServer()
Don't ever create an instance of MultiServer. Use the static fields, and call the static methods.

Method Detail

start

private static void start(java.lang.String[] argv)
Do actual work of starting the multiserver.


main

public static void main(java.lang.String[] argv)
The entry point for the stand-alone server. If an argument is passed in, it is assumed to be the location of the server config file. If no arguments are passed in, the default filename "./MultiServer.config" is used.


shutdown

public static void shutdown()
Shut down the server. This function stops all services.


getService

public static Service getService(java.lang.String name)
Get the named service.


readConfigFile

private static void readConfigFile(java.lang.String filename)
Parsing and implementing the config file. This sets up the server, according to the config file.


parseServerSection

private static void parseServerSection(com.lutris.util.Config server)
Retrieve the server parameters from the config file and establish the logging facility.


myGetString

private static java.lang.String myGetString(com.lutris.util.Config cfg,
                                            java.lang.String key)

myGetString

private static java.lang.String myGetString(com.lutris.util.Config cfg,
                                            java.lang.String key,
                                            java.lang.String prefix)

myGetStrings

private static java.lang.String[] myGetStrings(com.lutris.util.Config t,
                                               java.lang.String key,
                                               java.lang.String prefix)

myGetString

private static java.lang.String myGetString(com.lutris.util.Config cfg,
                                            java.lang.String key,
                                            java.lang.String prefix,
                                            boolean required)

myGetStrings

private static java.lang.String[] myGetStrings(com.lutris.util.Config t,
                                               java.lang.String key,
                                               java.lang.String prefix,
                                               boolean required)

myGetSection

private static com.lutris.util.Config myGetSection(com.lutris.util.Config cfg,
                                                   java.lang.String key)

myGetSection

private static com.lutris.util.Config myGetSection(com.lutris.util.Config cfg,
                                                   java.lang.String key,
                                                   boolean required)

trim

private static java.lang.String trim(java.lang.String s)

writeConfigFile

public static java.lang.String writeConfigFile(java.lang.String filename)
This function examines the current state of the server and writes it out to the same config file that was read when the server was started up.


getMaxMemoryUsage

public static long getMaxMemoryUsage()
This method if for getting the value that has been stored as highwater mark for memory usage by the virtual machine.


setMaxMemoryUsage

public static void setMaxMemoryUsage(long used)
This method is used for setting the highwater mark for the amount of memory that the virtual machine has used. The method does the appropriate checking to see if the value passed is greater than the current stored value.


resetMaxMemoryUsage

public static void resetMaxMemoryUsage()
This method is used to reset the maxMemoryUsage back to zero. This is so that new statistics can be gotten without restarting the application.


currentMemoryUsage

public static long currentMemoryUsage(boolean forceGC)
This method is used to get the current value of the amount of memory being used by the virtual machine.


fatalErr

private static void fatalErr(java.lang.String msg)

fatalErr

private static void fatalErr(java.lang.String msg,
                             java.lang.Throwable err)