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 (→Using Jetty XML) |
m |
||
Line 26: | Line 26: | ||
=== Using Jetty XML === | === 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.<ref>Ethan McAllum makes this point in his appreciative article about Jetty, [[http://onjava.com/pub/a/onjava/2006/06/14/what-is-jetty.html?page=3/What is Jetty]] | ||
+ | |||
The default configuration file for Jetty is <tt>jetty.xml</tt>, typically located at <tt>$JETTY_HOME/etc/jetty.xml</tt>. Usually <tt>jetty.xml</tt> configures these components: | The default configuration file for Jetty is <tt>jetty.xml</tt>, typically located at <tt>$JETTY_HOME/etc/jetty.xml</tt>. Usually <tt>jetty.xml</tt> configures these components: | ||
* the Server class (or subclass if extended) and global options | * the Server class (or subclass if extended) and global options | ||
Line 35: | Line 37: | ||
* a request log | * a request log | ||
− | Not all Jetty features are configured in <tt>jetty.xml</tt>. There are several optional configuration files that share the same format as <tt>jetty.xml</tt> and, if specified, concatenate to it. These configuration files are also stored in <tt>$JETTY_HOME/etc/</tt>, and examples of them are in [http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/jetty-server/src/main/config/etc/ svn]. [[Jetty/Feature/Start.jar| | + | Not all Jetty features are configured in <tt>jetty.xml</tt>. There are several optional configuration files that share the same format as <tt>jetty.xml</tt> and, if specified, concatenate to it. These configuration files are also stored in <tt>$JETTY_HOME/etc/</tt>, and examples of them are in [http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/jetty-server/src/main/config/etc/ svn]. [[Jetty/Feature/Start.jar|Start.jar]] selects the configuration files to use. [[Jetty/Reference/jetty.xml_usage|jetty.xml usage]] describes the process of merging configuration files. |
With [http://wiki.eclipse.org/Jetty/Reference/jetty.xml_usage Jetty XML] - dependency injection style XML format. | With [http://wiki.eclipse.org/Jetty/Reference/jetty.xml_usage Jetty XML] - dependency injection style XML format. |
Revision as of 11:59, 12 August 2010
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 a graphical representation 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:
#Using Your Favorite Dependency Injection Framework: Spring, XBean
#Using Jetty WebApp and Context Deployers
In Code
See 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]
Cite error: <ref>
tags exist, but no <references/>
tag was found