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

## org.archive.crawler
Class SimpleHttpServer

    java.lang.Object
      org.archive.crawler.SimpleHttpServer

    public class SimpleHttpServer

extends java.lang.Object

Wrapper for embedded Jetty server. Loads up all webapps under webapp directory.

Field Summary
`static int` | `DEFAULT_PORT` Default web port.

Constructor Summary
`SimpleHttpServer()`
`SimpleHttpServer(boolean localhostOnly, java.lang.String name, java.lang.String context, int port, boolean expandWebapps)` Deprecated. Use SimpleHttpServer(name,context,hosts,port,expandWebapps)
`SimpleHttpServer(int port, boolean expandWebapps)`
`SimpleHttpServer(java.util.List webapps, int port, boolean expandWebapps)`
`SimpleHttpServer(java.lang.String name, java.lang.String context, java.util.Collection<java.lang.String> hosts, int port, boolean expandWebapps)` Constructor.

Method Summary
`protected void` | `addWebapp(java.lang.String name, java.lang.String context, boolean expand)` Add a webapp.
`protected void` | `finalize()`
`java.util.Collection<java.lang.String>` | `getHosts()` Returns the hosts that the server is listening on.
`int` | `getPort()`
`static java.lang.String` | `getRootWebappName()`
`org.mortbay.http.HttpServer` | `getServer()`
`protected org.mortbay.http.RequestLog` | `getServerLogging()` Setup log files.
`java.io.File` | `getWebappPath(java.lang.String name)` Get path to named webapp.
`protected void` | `initialize(java.util.Collection<java.lang.String> hosts, int port)` Initialize the server.
`protected void` | `initialize(int port, boolean localhostOnly)` Deprecated. Use initialize(Collection, port) instead
`void` | `resetAuthentication(java.lang.String realmAndRoleName, java.lang.String oldUsername, java.lang.String newUsername, java.lang.String newPassword)` Reset the administrator login info.
`org.mortbay.http.HashUserRealm` | `setAuthentication(java.lang.String realmName, java.lang.String contextName, java.lang.String authProperties)` Setup a realm on the server named for the webapp and add to the passed webapp's context.
`void` | `setAuthentication(java.lang.String realmName, java.lang.String contextName, java.lang.String username, java.lang.String password, java.lang.String role)`
`void` | `startServer()` Start the server.
`void` | `stopServer()` Stop the running server.

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

Field Detail

### DEFAULT_PORT

    public static final int DEFAULT_PORT

  Default web port.

  See Also:
    Constant Field Values

Constructor Detail

### SimpleHttpServer

    public SimpleHttpServer()
                     throws java.lang.Exception

Throws:
  `java.lang.Exception`

### SimpleHttpServer

    public SimpleHttpServer(int port,
                            boolean expandWebapps)
                     throws java.lang.Exception

Throws:
  `java.lang.Exception`

### SimpleHttpServer

    public SimpleHttpServer(boolean localhostOnly,
                            java.lang.String name,
                            java.lang.String context,
                            int port,
                            boolean expandWebapps)
                     throws java.lang.Exception

  Deprecated. Use SimpleHttpServer(name,context,hosts,port,expandWebapps)

  Parameters:
    `name` - Name of webapp to load.
    `context` - Where to mount the webapp. If passed context is null or empty string, we'll use '/' + `name` else if passed '/' then we'll add the webapp as the root webapp.
    `port` - Port to run on.
    `expandWebapps` - True if we're to expand the webapp passed.
  Throws:
    `java.lang.Exception`

### SimpleHttpServer

    public SimpleHttpServer(java.lang.String name,
                            java.lang.String context,
                            java.util.Collection<java.lang.String> hosts,
                            int port,
                            boolean expandWebapps)
                     throws java.lang.Exception

  Constructor.

  Parameters:
    `name` - Name of webapp to load
    `context` - Where to mount the webap. If null or empty string, we'll use '/' + `name`; if passed '/' then we'll add the webapp as the root webapp
    `hosts` - list of hosts to bind to
    `port` - port to listen on
    `expandWebapps` - true to expand webapp passed
  Throws:
    `java.lang.Exception`

### SimpleHttpServer

    public SimpleHttpServer(java.util.List webapps,
                            int port,
                            boolean expandWebapps)
                     throws java.lang.Exception

Parameters:
  `webapps` - List of webapps to load.
  `port` - Port to run on.
  `expandWebapps` - True if we're to expand the webapps found.
Throws:
  `java.lang.Exception`

Method Detail

### addWebapp

    protected void addWebapp(java.lang.String name,
                             java.lang.String context,
                             boolean expand)
                      throws java.io.IOException

  Add a webapp.

  Parameters:
    `name` - Name of webapp to add.
    `context` - Context to add the webapp on.
    `expand` - True if we should expand the webapps.
  Throws:
    `java.io.IOException`

### initialize

    protected void initialize(int port,
                              boolean localhostOnly)

  Deprecated. Use initialize(Collection, port) instead

  Initialize the server. Called from constructors.

  Parameters:
    `port` - Port to start the server on.

### initialize

    protected void initialize(java.util.Collection<java.lang.String> hosts,
                              int port)

  Initialize the server. Called from constructors.

  Parameters:
    `hosts` - the hostnames to bind to; if empty or null, will bind to all interfaces
    `port` - the port to listen on

### getServerLogging

    protected org.mortbay.http.RequestLog getServerLogging()
                                                    throws java.lang.Exception

  Setup log files.

  Returns:
    RequestLog instance to add to a server.
  Throws:
    `java.lang.Exception`

### startServer

    public void startServer()
                     throws java.lang.Exception

  Start the server.

  Throws:
    `java.lang.Exception` - if problem starting server or if server already started.

### stopServer

    public void stopServer()
                    throws java.lang.InterruptedException

  Stop the running server.

  Throws:
    `java.lang.InterruptedException`

### finalize

    protected void finalize()
                     throws java.lang.Throwable

  Overrides:
    `finalize` in class `java.lang.Object`
  Throws:
    `java.lang.Throwable`

### getPort

    public int getPort()

  Returns:
    Port server is running on.

### getServer

    public org.mortbay.http.HttpServer getServer()

  Returns:
    Server reference.

### setAuthentication

    public org.mortbay.http.HashUserRealm setAuthentication(java.lang.String realmName,
                                                            java.lang.String contextName,
                                                            java.lang.String authProperties)
                                                     throws java.io.IOException

  Setup a realm on the server named for the webapp and add to the passed webapp's context. Used by the selftest to check digest authentication is working. For this all to work, the `web.xml` needs to set with a security constraint that points to a realm named for the passed webapp, `webappName`.

  Parameters:
    `realmName` - Name of realm to configure.
    `contextName` - Name of context we're using with this realm. If null, we'll use the realm name as context name.
    `authProperties` - Path to file that holds the auth login and password.
  Returns:
    Hash of user realms.
  Throws:
    `java.io.IOException`

### setAuthentication

    public void setAuthentication(java.lang.String realmName,
                                  java.lang.String contextName,
                                  java.lang.String username,
                                  java.lang.String password,
                                  java.lang.String role)
                           throws java.io.IOException

  Throws:
    `java.io.IOException`

### resetAuthentication

    public void resetAuthentication(java.lang.String realmAndRoleName,
                                    java.lang.String oldUsername,
                                    java.lang.String newUsername,
                                    java.lang.String newPassword)

  Reset the administrator login info.

  Parameters:
    `realmAndRoleName` - for our use, always 'admin'
    `oldUsername` - previous username to replace/disable
    `newUsername` - new username (may be same as old)
    `newPassword` - new password

### getWebappPath

    public java.io.File getWebappPath(java.lang.String name)

  Get path to named webapp.

  Parameters:
    `name` - Name of webpp. Possible names are 'admin' or 'selftest'.
  Returns:
    Path to deployed webapp.

### getRootWebappName

    public static java.lang.String getRootWebappName()

  Returns:
    Returns the root webapp name.

### getHosts

    public java.util.Collection<java.lang.String> getHosts()

  Returns the hosts that the server is listening on.

  Returns:
    the hosts that the server is listening on.

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

Copyright © 2003-2008 Internet Archive. All Rights Reserved.