SMILA 1.0 API documentation

org.eclipse.smila.http.server.internal
Class HttpServer

java.lang.Object
  extended by AbstractLifeCycle
      extended by org.eclipse.smila.http.server.internal.HttpServer

public class HttpServer
extends AbstractLifeCycle

Implements a HTTP server. (1) Create an instance of HttpServer. (2) Create an instance of HttpHandler. HttpHandler.handle will be invoked to process a request associated with the request URL path. The members of HttpExchange may be called to process the request and to generate the related response within HttpHandler.handle. (3) Create an instance of HttpContext to associate HttpHandler with a request URL path and pass it to HttpServer using HttpServer.addContext. (4) Repeat the steps (2) and (3), if more URL path/handler pairs are necessary. (5) Use HttpServer.start to start the server. (6) Use HttpServer.stop to stop the server.


Constructor Summary
HttpServer(XmlConfiguration configuration)
          create server from configuration.
 
Method Summary
 void addHttpHandler(HttpHandler smilaHandler)
          add a SMILA http handler to this server.
 void addJettyHandler(JettyHandler jettyHandler)
          add a context with a jetty-handler to this server.
protected  void doStart()
          
protected  void doStop()
          
protected  int getPort()
           
 void join()
          wait for server to shutdown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpServer

public HttpServer(XmlConfiguration configuration)
           throws java.lang.Exception
create server from configuration.

Parameters:
configuration - jetty.xml configuration
Throws:
java.lang.Exception - error creating server
Method Detail

getPort

protected int getPort()
Returns:
port of first connector, if any exist in server. Else -1

addHttpHandler

public void addHttpHandler(HttpHandler smilaHandler)
add a SMILA http handler to this server.

Parameters:
smilaHandler - a SMILA http handler to install.

addJettyHandler

public void addJettyHandler(JettyHandler jettyHandler)
add a context with a jetty-handler to this server.

Parameters:
jettyHandler - a JettyHandler to install

join

public void join()
          throws java.lang.InterruptedException
wait for server to shutdown.

Throws:
java.lang.InterruptedException - waiting was interrupted.

doStart

protected void doStart()

See Also:
AbstractLifeCycle#doStart()

doStop

protected void doStop()

See Also:
AbstractLifeCycle#doStop()

SMILA 1.0 API documentation