uk.org.iscream.cms.corbaservices
Class MiniWebServer

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--uk.org.iscream.cms.corbaservices.MiniWebServer
All Implemented Interfaces:
Runnable

public class MiniWebServer
extends Thread

MiniWebServer This provides a very basic webserver for serving IOR files. This could easily serve other text files, but not binaries.

Version:
$Id: MiniWebServer.java,v 1.9 2002/05/21 16:47:11 tdb Exp $
Author:
$Author: tdb $

Nested Class Summary
private  class MiniWebServer.Handler
          A Handler to deal with each client.
 
Field Summary
private  LinkedList _okUrls
          List of URLs that are permitted
private  String _okUrlsConfig
          Config file for the URL list
private  long _okUrlsConfigStamp
          Timestamp of the URL config file
private  int _port
          The port we're bound to.
private  String _webDir
          Web directory
static String REVISION
          The current CVS revision of this class
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MiniWebServer(int port, String okUrlsConfig, String webDir)
          Construct a new MiniWebServer
 
Method Summary
private  boolean okUrl(String url)
          Checks if an URL is allowed.
private  void readOkUrls()
          Reads the list of URLs into a list.
private  String readUrl(String url)
          Reads a file in given an URL.
 void run()
          Main thread of execution.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

_port

private int _port
The port we're bound to.


_okUrls

private LinkedList _okUrls
List of URLs that are permitted


_okUrlsConfig

private String _okUrlsConfig
Config file for the URL list


_okUrlsConfigStamp

private long _okUrlsConfigStamp
Timestamp of the URL config file


_webDir

private String _webDir
Web directory

Constructor Detail

MiniWebServer

public MiniWebServer(int port,
                     String okUrlsConfig,
                     String webDir)
Construct a new MiniWebServer

Parameters:
port - The port to bind to
okUrlsConfig - The URL list config file
webDir - The web directory
Method Detail

run

public void run()
Main thread of execution. Keeps looping spawning off Handler's to deal with each client. This should keep going, and extra care has been taking with error catching.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

readUrl

private String readUrl(String url)
Reads a file in given an URL. Very basic, and has only been tested to work for URL's in the / directory.

Parameters:
url - The URL given to the webserver
Returns:
A String containing data from the file

okUrl

private boolean okUrl(String url)
Checks if an URL is allowed. Failure of this method indicates a client should be sent a 403.

Parameters:
url - the url to check
Returns:
whether the url is permitted

readOkUrls

private void readOkUrls()
Reads the list of URLs into a list.



Copyright © 2000-2003 i-scream. All Rights Reserved.