All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class calypso.core.httpserver.HttpServer

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----calypso.core.httpserver.HttpServer

public class HttpServer
extends Thread
implements HttpServerConstants
HttpServer class used for accepting new connections to the server. The connections are accepted in a single thread of HttpServer and all the requests are handled in waiting HttpConnectionHandlers. All the connection handlers are created once the HTTP server is first started. Requests are stored in pendingConns Queue.

Version:
1.0
Author:
Olli-Pekka Auvinen / TCM laboratory / HUT
See Also:
HttpConnectionHandler, HttpServerConstants

Variable Index

 o handlerPool
The synchronization object representing the 'handler pool'.
 o pendingConns
The queue of waiting connections.

Constructor Index

 o HttpServer(ThreadGroup)
The constructor for HttpServer.

Method Index

 o checkProperties()
Static check method for server properties.
 o getIntProperty(String)
Static access method for integer type of property.
 o getProperty(String)
Static access method for properties.
 o getServletLoader()
Access method for Servlet Loader.
 o init()
The method for initializing the HttpServer.
 o init(String)
The method for initializing the HttpServer.
 o main(String[])
 o run()
The run method for the server accepting new connections.
 o windDown()
Method for finalizing the HTTP server.

Variables

 o handlerPool
 protected static final Object handlerPool
The synchronization object representing the 'handler pool'. All the handler thread are synchronized in respect to handler pool.

 o pendingConns
 protected Queue pendingConns
The queue of waiting connections. Once a new connection is accepted the Socket is stored in pendingConns Queue.

Constructors

 o HttpServer
 public HttpServer(ThreadGroup serverThreads_) throws HttpServerException
The constructor for HttpServer. The handlers are created and started in the constructor body. Initially all the handlers start to wait for requests in 'handler pool'.

Parameters:
serverPort_ - The port number of accepting connections.
documentRoot_ - Root directory for retrievable documents.
Throws: HttpServerException
Whenever the constructor fails.

Methods

 o run
 public void run()
The run method for the server accepting new connections. Requests are accepted and inserted into pendingConns here, then the 'handler pool' is notified for a handler to start serving the gotten request.

Overrides:
run in class Thread
 o getServletLoader
 protected ServletLoader getServletLoader()
Access method for Servlet Loader.

Returns:
The Servlet Loader of the HTTP Server.
 o windDown
 public void windDown()
Method for finalizing the HTTP server. In cleanup procedures the unloading of all the loaded Servlets will be made by calling the ServletLoader's unloading method.

 o init
 public static HttpServer init()
The method for initializing the HttpServer. The method is responsible for loading the HTTP server properties. If no arguments are given the server loads the default properties file. Additionally a new HttpServer is created and its running is started in a thread.

 o init
 public static HttpServer init(String propFile_)
The method for initializing the HttpServer. The method is responsible for loading the HTTP server properties. The customised properties file is given as an argument. Additionally a new HttpServer is created and its running is started in a thread.

Parameters:
propFile_ - Properties file for HttpServer.
 o getIntProperty
 protected static int getIntProperty(String propName_)
Static access method for integer type of property.

Parameters:
propName_ - The name of the desired property.
Returns:
The integer value of the desired property, -1 if something went wrong.
 o getProperty
 protected static String getProperty(String propName_)
Static access method for properties.

Parameters:
propName_ - The name of the desired property.
Returns:
The String value of the desired property, null if something went wrong.
 o checkProperties
 protected static void checkProperties() throws HttpServerException
Static check method for server properties.

Throws: HttpServerException
if server properties are invalid.
 o main
 public static void main(String argv[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index