org.mortbay.p2psockets.jetty
Class P2PServer

java.lang.Object
  extended byServer
      extended byorg.mortbay.p2psockets.jetty.P2PServer

public class P2PServer
extends Server

The Jetty HttpServer modified to work on the Jxta P2P network. This specialization of org.mortbay.http.HttpServer adds knowledge about servlets and their specialized contexts. It also included support for initialization from xml configuration files that follow the XmlConfiguration dtd. HttpContexts created by Server are of the type org.mortbay.jetty.servlet.ServletHttpContext unless otherwise specified. This class also provides a main() method which starts a server for each config file passed on the command line. If the system property JETTY_NO_SHUTDOWN_HOOK is not set to true, then a shutdown hook is thread is registered to stop these servers.

Version:
$Revision: 1.1 $
Author:
Greg Wilkins (gregw), Brad GNUberg, bkn3@columbia.edu - Added Jxta support.
See Also:
org.mortbay.xml.XmlConfiguration, org.mortbay.jetty.servlet.ServletHttpContext, Serialized Form

Field Summary
static java.lang.String JETTY_HOST
          The system property name for the host name to use when starting up this Jety server.
static java.lang.String JETTY_PORT
          The system property name for the port to use when starting up this Jety server.
 
Constructor Summary
P2PServer()
          Constructor.
P2PServer(java.lang.String configuration)
          Constructor.
P2PServer(java.net.URL configuration)
          Constructor.
 
Method Summary
 WebApplicationContext addWebApplication(java.lang.String contextPathSpec, java.lang.String webApp)
          Add Web Application.
 WebApplicationContext addWebApplication(java.lang.String virtualHost, java.lang.String contextPathSpec, java.lang.String webApp)
          Add Web Application.
 WebApplicationContext addWebApplication(java.lang.String contextPathSpec, java.lang.String webApp, java.lang.String defaults, boolean extractWar)
          Deprecated. use addWebApplicaton(host,path,webapp)
 WebApplicationContext addWebApplication(java.lang.String virtualHost, java.lang.String contextPathSpec, java.lang.String webApp, java.lang.String defaults, boolean extractWar)
          Deprecated. use addWebApplicaton(host,path,webapp)
 WebApplicationContext[] addWebApplications(java.lang.String webapps)
          Add Web Applications.
 WebApplicationContext[] addWebApplications(java.lang.String host, java.lang.String webapps)
          Add Web Applications.
 WebApplicationContext[] addWebApplications(java.lang.String host, java.lang.String webapps, boolean extract)
          Add Web Applications.
 WebApplicationContext[] addWebApplications(java.lang.String host, java.lang.String webapps, java.lang.String defaults, boolean extract)
          Add Web Applications.
 void configure(java.lang.String configuration)
          Configure the server from an XML file.
 java.lang.String getConfiguration()
           
static void main(java.lang.String[] arg)
           
protected  HttpContext newHttpContext()
          Create a new ServletHttpContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JETTY_HOST

public static java.lang.String JETTY_HOST
The system property name for the host name to use when starting up this Jety server. Added by bkn3@columbia.edu.


JETTY_PORT

public static java.lang.String JETTY_PORT
The system property name for the port to use when starting up this Jety server. Added by bkn3@columbia.edu.

Constructor Detail

P2PServer

public P2PServer()
Constructor.


P2PServer

public P2PServer(java.lang.String configuration)
          throws java.io.IOException
Constructor.

Parameters:
configuration - The filename or URL of the XML configuration file.

P2PServer

public P2PServer(java.net.URL configuration)
          throws java.io.IOException
Constructor.

Parameters:
configuration - The filename or URL of the XML configuration file.
Method Detail

configure

public void configure(java.lang.String configuration)
               throws java.io.IOException
Configure the server from an XML file.

Parameters:
configuration - The filename or URL of the XML configuration file.
Throws:
java.io.IOException

getConfiguration

public java.lang.String getConfiguration()

newHttpContext

protected HttpContext newHttpContext()
Create a new ServletHttpContext. Ths method is called by HttpServer to creat new contexts. Thus calls to addContext or getContext that result in a new Context being created will return an org.mortbay.jetty.servlet.ServletHttpContext instance.

Returns:
ServletHttpContext

addWebApplication

public WebApplicationContext addWebApplication(java.lang.String contextPathSpec,
                                               java.lang.String webApp)
                                        throws java.io.IOException
Add Web Application.

Parameters:
contextPathSpec - The context path spec. Which must be of the form / or /path/*
webApp - The Web application directory or WAR file.
Returns:
The WebApplicationContext
Throws:
java.io.IOException

addWebApplication

public WebApplicationContext addWebApplication(java.lang.String virtualHost,
                                               java.lang.String contextPathSpec,
                                               java.lang.String webApp)
                                        throws java.io.IOException
Add Web Application.

Parameters:
virtualHost - Virtual host name or null
contextPathSpec - The context path spec. Which must be of the form / or /path/*
webApp - The Web application directory or WAR file.
Returns:
The WebApplicationContext
Throws:
java.io.IOException

addWebApplications

public WebApplicationContext[] addWebApplications(java.lang.String webapps)
                                           throws java.io.IOException
Add Web Applications. Add auto webapplications to the server. The name of the webapp directory or war is used as the context name. If a webapp is called "root" it is added at "/".

Parameters:
webapps - Directory file name or URL to look for auto webapplication.
Throws:
java.io.IOException

addWebApplications

public WebApplicationContext[] addWebApplications(java.lang.String host,
                                                  java.lang.String webapps)
                                           throws java.io.IOException
Add Web Applications. Add auto webapplications to the server. The name of the webapp directory or war is used as the context name. If a webapp is called "root" it is added at "/".

Parameters:
host - Virtual host name or null
webapps - Directory file name or URL to look for auto webapplication.
Throws:
java.io.IOException

addWebApplications

public WebApplicationContext[] addWebApplications(java.lang.String host,
                                                  java.lang.String webapps,
                                                  boolean extract)
                                           throws java.io.IOException
Add Web Applications. Add auto webapplications to the server. The name of the webapp directory or war is used as the context name. If a webapp is called "root" it is added at "/".

Parameters:
host - Virtual host name or null
webapps - Directory file name or URL to look for auto webapplication.
extract - If true, extract war files
Throws:
java.io.IOException

addWebApplications

public WebApplicationContext[] addWebApplications(java.lang.String host,
                                                  java.lang.String webapps,
                                                  java.lang.String defaults,
                                                  boolean extract)
                                           throws java.io.IOException
Add Web Applications. Add auto webapplications to the server. The name of the webapp directory or war is used as the context name. If a webapp is called "root" it is added at "/".

Parameters:
host - Virtual host name or null
webapps - Directory file name or URL to look for auto webapplication.
defaults - The defaults xml filename or URL which is loaded before any in the web app. Must respect the web.dtd. If null the default defaults file is used. If the empty string, then no defaults file is used.
extract - If true, extract war files
Throws:
java.io.IOException

addWebApplication

public WebApplicationContext addWebApplication(java.lang.String contextPathSpec,
                                               java.lang.String webApp,
                                               java.lang.String defaults,
                                               boolean extractWar)
                                        throws java.io.IOException
Deprecated. use addWebApplicaton(host,path,webapp)

Add Web Application.

Parameters:
contextPathSpec - The context path spec. Which must be of the form / or /path/*
webApp - The Web application directory or WAR as file or URL.
defaults - The defaults xml filename or URL which is loaded before any in the web app. Must respect the web.dtd. Normally this is passed the file $JETTY_HOME/etc/webdefault.xml
extractWar - If true, WAR files are extracted to the webapp subdirectory of the contexts temporary directory.
Returns:
The WebApplicationContext
Throws:
java.io.IOException

addWebApplication

public WebApplicationContext addWebApplication(java.lang.String virtualHost,
                                               java.lang.String contextPathSpec,
                                               java.lang.String webApp,
                                               java.lang.String defaults,
                                               boolean extractWar)
                                        throws java.io.IOException
Deprecated. use addWebApplicaton(host,path,webapp)

Add Web Application.

Parameters:
virtualHost - Virtual host name or null
contextPathSpec - The context path spec. Which must be of the form / or /path/*
webApp - The Web application directory or WAR file.
defaults - The defaults xml filename or URL which is loaded before any in the web app. Must respect the web.dtd. Normally this is passed the file $JETTY_HOME/etc/webdefault.xml
extractWar - If true, WAR files are extracted to the webapp subdirectory of the contexts temporary directory.
Returns:
The WebApplicationContext
Throws:
java.io.IOException

main

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