Standalone Server
Circumflex Web Framework ships StandaloneServer which uses Jetty under the curtains. It can be used to start server manually (e.g. via Scala console). Usage is simple: use start method to bring standalone server up and stop method to shut the server down. Initialization are not synchronized, so if you intend dynamic start-stop functionality, consider external synchronization.
The best practice for setting up the standalone server is to provide a singleton object:
object MyServer extends StandaloneServer
Following configuration parameters are required to get standalone server up and running:
cx.webappRoot specifies content root of web application (src/main/webapp is default);
cx.contextPath specifies the context path of web application (/ by default);
cx.port specifies port which Jetty will listen to.
Jetty's WebAppContext is used as default requests handler: it provides sensible defaults for almost every web application startup (it reads configuration from web.xml and all other Jetty-specific descriptors). You can override default handler:
object MyServer extends StandaloneServer {
context(new JettyContext(...))
}
You can also supply your own implementation of Jetty's Server :
object MyServer extends StandaloneServer {
server(new JettyServer(...))
}
Refer to Jetty documentation for more information.
|