Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Jetty/Howto/Configure Jetty"
m |
m |
||
Line 48: | Line 48: | ||
* [[Jetty/Feature/Start.jar|Start.jar]] selects the configuration files to use. | * [[Jetty/Feature/Start.jar|Start.jar]] selects the configuration files to use. | ||
− | * [[Jetty/Reference/jetty.xml_usage|jetty | + | * [[Jetty/Reference/jetty.xml_usage|jetty XML Usage]] describes the process of merging configuration files. |
* [[Jetty/Reference/jetty.xml_syntax|Jetty.xml Syntax ]] describes the syntax for using [[Jetty/Reference/jetty.xml|jetty.xml]] | * [[Jetty/Reference/jetty.xml_syntax|Jetty.xml Syntax ]] describes the syntax for using [[Jetty/Reference/jetty.xml|jetty.xml]] | ||
− | * [[Jetty/Reference | + | ==== Additional Resources ==== |
+ | * [http://www.eclipse.org/jetty/configure.dtd configure.dtd] | ||
+ | * [[Jetty/Reference/jetty.xml| jetty.xml, Server configuration file]] | ||
+ | * [[Jetty/Reference/jetty-web.xml| jetty-web.xml, Webapp configuration file]] | ||
+ | * [[Jetty/Reference/jetty-env.xml| jetty-env.xml, JNDI configuration file]] | ||
+ | * [[/webdefault.xml|webdefault.xml]] - Pre-web.xml configuration | ||
+ | * [[/override-web.xml|override-web.xml]] - Post-web.xml configuration | ||
=== Embedding Jetty === | === Embedding Jetty === |
Revision as of 16:04, 13 August 2010
Contents
Introduction
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 graphical representations of the interactions among connectors and handlers.
Configuring Jetty
Since Jetty components are simply Plain Old Java Objects (POJOs), you can accomplish this assembly and configuration of Jetty by a variety of techniques:
#IDeveloping Against the Jetty API
#Using Your Favorite Dependency Injection Framework: Spring, XBean
#Using Jetty WebApp and Context Deployers
Developing Against the Jetty API
You can develop both standard web applications and embedded web applications by writing code. The basic approach is to install the required Jetty-7 jars and dependencies on your class path and then write and run a variation of one of the examples in the Embedding Jetty Tutorial.
For more details about setting up your class path, see:
For more information on developing against the Jetty API, as well as explanations of other tools, including the Jetty Maven, Ant, and OSGi plugins, see: How to Develop Jetty.
Above all, study the examples in the Jetty 7 Latest Source XRef.
Using Jetty XML
Jetty 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.[1]
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
Not all Jetty features are configured in jetty.xml. There are several optional configuration files that share the same format as jetty.xml and, if specified, concatenate to it. These configuration files are also stored in $JETTY_HOME/etc/, and examples of them are in svn.
- Start.jar selects the configuration files to use.
- jetty XML Usage describes the process of merging configuration files.
- Jetty.xml Syntax describes the syntax for using jetty.xml
Additional Resources
- configure.dtd
- jetty.xml, Server configuration file
- jetty-web.xml, Webapp configuration file
- jetty-env.xml, JNDI configuration file
- webdefault.xml - Pre-web.xml configuration
- override-web.xml - Post-web.xml configuration
Embedding Jetty
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
More
For more configuration references, see the Jetty Configuration Reference pages. For
Finally
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.
References
- ↑ Ethan McAllum makes this point in his appreciative article about Jetty, What is Jetty