Package org.gwizard.web
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.ServletContextHandlercreateRootServletContextHandler()Overrideable method to create the root ServletContextHandler.protected org.eclipse.jetty.server.ServercreateServer(WebConfig webConfig)Overrideable method to create the initial jetty Server.voidstart()Start the web server.voidstop()signal the web server to stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
WebServer
@Inject public WebServer(WebConfig webConfig, EventListenerScanner eventListenerScanner, HandlerScanner handlerScanner)
-
-
Method Details
-
start
public void start() throws java.lang.ExceptionStart 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
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.Exceptionsignal the web server to stop- Throws:
java.lang.Exception
-