Class WebServer

java.lang.Object
org.gwizard.web.WebServer

@Singleton
public class WebServer
extends java.lang.Object
Simple Jetty-based embedded web server which configures itself from a bound WebConfig and serves the GuiceFilter so you can manage web content with Guice ServletModules. Also clever enough to add any EventListener objects found in the injector bindings.
  • Constructor Summary

    Constructors
    Constructor Description
    WebServer​(WebConfig webConfig, EventListenerScanner eventListenerScanner, HandlerScanner handlerScanner)  
  • Method Summary

    Modifier and Type Method Description
    protected org.eclipse.jetty.servlet.ServletContextHandler createRootServletContextHandler()
    Overrideable method to create the root ServletContextHandler.
    protected org.eclipse.jetty.server.Server createServer​(WebConfig webConfig)
    Overrideable method to create the initial jetty Server.
    void start()
    Start the web server.
    void stop()
    signal the web server to stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • start

      public void start() throws java.lang.Exception
      Start the web server. Does not block.
      Throws:
      java.lang.Exception
      See Also:
      AbstractLifeCycle.start()
    • createRootServletContextHandler

      protected org.eclipse.jetty.servlet.ServletContextHandler createRootServletContextHandler()
      Overrideable method to create the root ServletContextHandler. This can be used so that the Server can have a ServletContextHandler that will be able to handle Sessions for example. By default we create a bare-bones ServletContextHandler that is not set up to handle Sessions.
    • createServer

      protected org.eclipse.jetty.server.Server createServer​(WebConfig webConfig)
      Overrideable method to create the initial jetty Server. We need to draw a lot more configuration parameters into WebConfig, but for now this gives users a hook to satisfy their needs. Bind a subclass to WebConfig, subclass this WebServer, and change behavior to whatever you want.
    • stop

      public void stop() throws java.lang.Exception
      signal the web server to stop
      Throws:
      java.lang.Exception