chrriis.common
Class WebServer

java.lang.Object
  extended by chrriis.common.WebServer

public class WebServer
extends Object

Author:
Christopher Deckers

Nested Class Summary
static class WebServer.HTTPData
           
static class WebServer.HTTPRequest
           
static class WebServer.WebServerContent
           
static interface WebServer.WebServerContentProvider
          A content provider for global resources.
 
Constructor Summary
WebServer()
           
WebServer(int port)
           
 
Method Summary
 void addContentProvider(WebServer.WebServerContentProvider webServerContentProvider)
          Add a content provider for content that is not natively supported by the web server.
 void addReferenceClassLoader(ClassLoader referenceClassLoader)
           
 String getClassPathResourceURL(String className, String resourcePath)
           
static WebServer getDefaultWebServer()
           
 String getDynamicContentURL(String className, String parameter)
           
 String getDynamicContentURL(String className, String codebase, String parameter)
           
 int getPort()
           
 String getResourcePathURL(String codeBase, String resourcePath)
           
 WebServer.WebServerContent getURLContent(String resourceURL)
           
 String getURLPrefix()
           
protected static WebServer.WebServerContent getWebServerContent(WebServer.HTTPRequest httpRequest)
           
 boolean isRunning()
           
 void removeContentProvider(WebServer.WebServerContentProvider webServerContentProvider)
          Remove a content provider.
 void removeReferenceClassLoader(ClassLoader referenceClassLoader)
           
 void start()
           
 void start(boolean isDaemon)
           
 void stop()
           
static void stopDefaultWebServer()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebServer

public WebServer()

WebServer

public WebServer(int port)
Method Detail

stop

public void stop()

isRunning

public boolean isRunning()

start

public void start()
           throws IOException
Throws:
IOException

start

public void start(boolean isDaemon)
           throws IOException
Throws:
IOException

getPort

public int getPort()

getURLPrefix

public String getURLPrefix()

getDynamicContentURL

public String getDynamicContentURL(String className,
                                   String parameter)
Returns:
A URL that when accessed will invoke the method static WebServerContent getWebServerContent(HTTPRequest) of the parameter class (the method visibility does not matter).

getDynamicContentURL

public String getDynamicContentURL(String className,
                                   String codebase,
                                   String parameter)
Returns:
A URL that when accessed will invoke the method static WebServerContent getWebServerContent(HTTPRequest) of the parameter class (the method visibility does not matter).

getClassPathResourceURL

public String getClassPathResourceURL(String className,
                                      String resourcePath)

getResourcePathURL

public String getResourcePathURL(String codeBase,
                                 String resourcePath)

getURLContent

public WebServer.WebServerContent getURLContent(String resourceURL)

addReferenceClassLoader

public void addReferenceClassLoader(ClassLoader referenceClassLoader)

removeReferenceClassLoader

public void removeReferenceClassLoader(ClassLoader referenceClassLoader)

addContentProvider

public void addContentProvider(WebServer.WebServerContentProvider webServerContentProvider)
Add a content provider for content that is not natively supported by the web server.

Parameters:
webServerContentProvider - the content provider to add.

removeContentProvider

public void removeContentProvider(WebServer.WebServerContentProvider webServerContentProvider)
Remove a content provider.

Parameters:
webServerContentProvider - the content provider to remove.

getWebServerContent

protected static WebServer.WebServerContent getWebServerContent(WebServer.HTTPRequest httpRequest)

stopDefaultWebServer

public static void stopDefaultWebServer()

getDefaultWebServer

public static WebServer getDefaultWebServer()