Configuring jetty consists of building a network of connectors and handlers and providing their individual configurations. It is a combination of
- HTTP server configuration (ports, thread pools, buffers, etc.)
- Web container configuration (webapps deployment, security realms, JNDI etc.)
- Web application (init parameters, non standard options, etc.)
See Jetty Architecture for a graphical representation of the interactions among connectors and handlers.
Since Jetty components are simply Plain Old Java Objects (POJOs), you can accomplish this assembly and configuration of Jetty by a variety of techniques:
See the examples in the Jetty 7 Latest Source XRef.
Using Jetty XMLJetty XML offers XML equivalents to code. It is based on Java's Reflection API. Classes in the java.lang.reflect represent Java methods and classes, such that you can instantiate objects and invoke their methods based on their names and argument types. Behind the scenes, Jetty's XML config parser translates the XML elements and attributes into Reflection calls.
- Ethan McAllum makes this point in his appreciative article about Jetty, [is Jetty]
The default configuration file for Jetty is jetty.xml, typically located at $JETTY_HOME/etc/jetty.xml. Usually jetty.xml configures these components:
- the Server class (or subclass if extended) and global options
- a ThreadPool (min & max thread)
- connectors (ports, timeouts, buffer sizes, protocol, etc.)
- the handler structure (default handlers and/or a contextHandlerCollections, etc.)
- the deployment manager that scans for and deploys webapps and contexts
- login services that provide authentication checking.
- a request log
Using the Jetty Maven Plugin
Using Your Favorite Dependency Injection Framework: Spring, XBean
Configuring Jetty with Spring
Configuring Jetty with XBean
Using Jetty WebApp and Context Deployers
For more configuration references, see the Jetty Configuration Reference pages.
Because Jetty configuration can be considered as calling setters on a collection of POJOs, regardless of the actual method used, the apidocs are the ultimate resource for configuration.