: Class Server

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mortbay.Jetty
Class Server

    java.lang.Object
      |
      +--com.mortbay.HTTP.Configure.BaseConfiguration
            |
            +--com.mortbay.Jetty.Server

public class Server
extends BaseConfiguration

A configuration file based Jetty HttpServer. This HttpConfiguration class uses PropertyTree based files to configure and run 1 or more Jetty HttpServer instances. The loadConfigurationFile and buildServers static methods construct 1 or more instances of Server that can be started with the startAll method.

#### Notes

An IP address of 0.0.0.0 can be used to indicate all local addresses.

Version:
  $Id: Server.java,v 1.17 2000/10/20 16:44:50 pbannister Exp $
Author:
  Greg Wilkins (wilkinsg)
See Also:
  `PropertyTree`, `HttpServer`, `PathMap`

Fields inherited from class com.mortbay.HTTP.Configure.BaseConfiguration
`addresses, attributes, exceptionHandlersMap, httpHandlersMap, listenerClasses, mimeMap, properties`

Constructor Summary
`Server(java.lang.String serverName, PropertyTree listeners, java.util.Properties properties)` Constructor.

Method Summary
`void` | `addExceptionStack(java.lang.String stackName, PropertyTree stackTree)` Add an exception handler stack to the server.
`void` | `addHandlerStack(java.lang.String stackName, PropertyTree stackTree)` Add a handler stack to the server.
`static void` | `buildServer(java.lang.String serverName, PropertyTree serverTree)` Build and configure a Server from a PropertyTree.
`static void` | `buildServers(PropertyTree serversTree)` Configure 1 or more Server instances.
`static java.lang.String` | `getGlobalProperty(java.lang.String name)` Get a JVM wide server property.
`java.lang.String` | `getServerName()` The server name
`void` | `join()` join
`static void` | `loadConfigurationFile(java.lang.String filename)` Load server configuration file.
`static void` | `main(java.lang.String[] args)` main
`static java.util.Enumeration` | `servers()` Get all configured servers.
`static void` | `shutdown()` Deprecated. Use stopAll.
`void` | `start()` Start serving.
`static void` | `startAll()` Start all configured servers.
`void` | `stop()` Stop serving.
`static void` | `stopAll()` Stop all configured servers.

Methods inherited from class com.mortbay.HTTP.Configure.BaseConfiguration
`addresses, exceptionHandlersMap, getAttribute, getMimeByExtension, getMimeType, getProperties, getProperty, httpHandlersMap, listenerClasses, log, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Server

    public Server(java.lang.String serverName,
                  PropertyTree listeners,
                  java.util.Properties properties)
           throws java.lang.Exception

  Constructor. Construct a server from a property tree of listeners and a properti instance of other parameters. The server will be constructed without any handlers and addHandlerStack will need to be called before starting the server. The listeners PropertyTree should have the following structure:

       name1.CLASS   : com.mortbay.HTTP.HttpListener
       name1.ADDRS   : ipaddress:port;ipaddress:port;...
       name2.CLASS   : com.mortbay.HTTP.HttpListener
       name2.ADDRS   : ipaddress:port;ipaddress:port;...

  Currently the following properties are defined for the server property instance:

       SessionMaxInactiveInterval : Max idle time MS before session death
       MinListenerThreads         : Min listener threads per listener
       MaxListenerThreads         : Max listener threads per listener
       MaxListenerThreadIdleMs    : Max idle time Ms before listen thread
                                    death
       MimeMap                    : Property file of MIME mappings

  Note that if this method is called from buildServer, then all properties in the original file will be prefixed with "servername.stackname.".
  Parameters:
    `serverName` - The servers name
    `listeners` - Listener PropertyTree
    `properties` - Server properties
  Throws:
    java.lang.Exception -

Method Detail

### getGlobalProperty

    public static java.lang.String getGlobalProperty(java.lang.String name)

  Get a JVM wide server property.

### loadConfigurationFile

    public static void loadConfigurationFile(java.lang.String filename)
                                      throws java.lang.Exception

  Load server configuration file.
  Parameters:
    `filename` - The configuration file (see buildServers for format).
  Throws:
    java.lang.Exception - Problem loading file or configuring servers.

### buildServers

    public static void buildServers(PropertyTree serversTree)
                             throws java.lang.Exception

  Configure 1 or more Server instances. Build server instances from the contents of the passed property tree. The contents of the property tree must be structured as follows:

       SETUID                   : User ID to run server as if started as
                                  root under unix.  Uses native method to
                                  call setuid.
       SERVERS                  : servername1;servername2
       PROPERTY.GlobalProperty  : GlobalValue
       PROPERTIES               : FileOfGlobalProperties.prp
       servername1.*            : *
       servername2.*            : *

  For each server listed in SERVERS, the buildServer method is called with the PropertyTree built from all properties starting with "servername.". The "DefaultPageType" parameter can be set in the Global paramters to define the default Page class for all servers.
  Parameters:
    `serversTree` - The server properties

### buildServer

    public static void buildServer(java.lang.String serverName,
                                   PropertyTree serverTree)
                            throws java.lang.Exception

  Build and configure a Server from a PropertyTree. A new server is constructed and 1 or more handler stacks are added to it from the configuration described in the PropertyTree, such as:

       CLASS                   : com.mortbay.HTTP.HttpServer
       STACKS                  : stackname1;stackname2;...
       EXCEPTIONS              : exstackname1;exstackname2;...
       PROPERTY.ServerProperty : ServerValue
       PROPERTIES              : FileOfServerProperties.
       LISTENER.name.CLASS     : com.mortbay.HTTP.HttpListener
       LISTENER.name.ADDRS     : 0.0.0.0:8080
       stackname1.*            : *
       stackname2.*            : *
       exstackname1.*          : *
       exstackname2.*          : *

  The server is constructed by passing it the server properties and the listener PropertyTree. Then for each listed handler stack, the addHandlerStack method is called called with the PropertyTree built from all properties starting with "stackname." Note that if this method is called from buildServers, then all properties in the original file will be prefixed with "servername.".
  Parameters:
    `serverName` - The name of the server.
    `serverTree` - configuration property tree.
  Throws:
    java.lang.Exception -

### servers

    public static java.util.Enumeration servers()

  Get all configured servers.
  Returns:
    Enumeration of Server instances.

### startAll

    public static void startAll()
                         throws java.lang.Exception

  Start all configured servers. If a User ID is configured on a Unix system, a native call is made to set the effective User ID after the servers have been started.

### stopAll

    public static void stopAll()

  Stop all configured servers.

### shutdown

    public static void shutdown()

  Deprecated. Use stopAll.

  shutdown

### getServerName

    public java.lang.String getServerName()

  The server name
  Returns:
    The server name.

### addHandlerStack

    public void addHandlerStack(java.lang.String stackName,
                                PropertyTree stackTree)
                         throws java.lang.Exception

  Add a handler stack to the server. A stack of handlers is contructed and configured from a PropertyTree with a structure like:

       PATHS                   : pathSpec;pathSpec;...
       HANDLERS                : handlername1;handlername2;...
       handlername1.CLASS      : package.handler1class
       handlername1.PROPERTY.* : *
       handlername1.PROPERTIES : handler1PropertyFile.prp
       handlername2.*          : *
       ...

  The stack of handlers is constructed in the order specified by the HANDLERS parameter and registered at each of the PathMap path specifications listed in PATHS. Each handler is constructed with a constructor taking a properties instance which is initialized from the PROPERTY and/or PROPERTIES paramaters. Note that if this method is called from buildServer, then all properties in the original file will be prefixed with "servername.stackname.".
  Parameters:
    `stackName` - The name of the handler stack
    `stackTree` - PopertyTree describing the stack
  Throws:
    java.lang.Exception -

### addExceptionStack

    public void addExceptionStack(java.lang.String stackName,
                                  PropertyTree stackTree)
                           throws java.lang.Exception

  Add an exception handler stack to the server. A stack of exception handlers is contructed and configured from a PropertyTree with a structure like:

       PATHS                   : pathSpec;pathSpec;...
       HANDLERS                : handlername1;handlername2;...
       handlername1.CLASS      : package.handler1class
       handlername1.PROPERTY.* : *
            * ...

  The stack of handlers is constructed in the order specified by the HANDLERS parameter and registered at each of the PathMap path specifications listed in PATHS. Note that if this method is called from buildServer, then all properties in the original file will be prefixed with "servername.stackname.".
  Parameters:
    `stackName` - The name of the exception handler stack
    `stackTree` - PopertyTree describing the stack
  Throws:
    java.lang.Exception -

### start

    public void start()
               throws java.lang.Exception

  Start serving.

### stop

    public void stop()

  Stop serving.

### join

    public void join()
              throws java.lang.InterruptedException

  join

### main

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

  main
  Parameters:
    `args` - optional property file name

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD