| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Chapter 34. Reference Section</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><meta name="keywords" content="jetty, servlet, servlet-api, cometd, http, websocket, eclipse, maven, java, server, software"><link rel="home" href="index.html" title="Jetty : The Definitive Reference"><link rel="up" href="reference.html" title="Part V. Reference Guide"><link rel="prev" href="release-testing.html" title="Testing a Jetty Release"><link rel="next" href="jetty-xml-usage.html" title="Jetty XML Usage"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><script type="text/javascript" src="js/shCore.js"></script><script type="text/javascript" src="js/shBrushJava.js"></script><script type="text/javascript" src="js/shBrushXml.js"></script><script type="text/javascript" src="js/shBrushBash.js"></script><script type="text/javascript" src="js/shBrushJScript.js"></script><script type="text/javascript" src="js/shBrushSql.js"></script><script type="text/javascript" src="js/shBrushProperties.js"></script><script type="text/javascript" src="js/shBrushPlain.js"></script><link type="text/css" rel="stylesheet" href="css/shCore.css"><link type="text/css" rel="stylesheet" href="css/shThemeEclipse.css"><link type="text/css" rel="stylesheet" href="css/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small"> |
| Version: 9.3.0.v20150612</span></td><td style="width: 50%"><script type="text/javascript"> (function() { |
| var cx = '016459005284625897022:obd4lsai2ds'; |
| var gcse = document.createElement('script'); |
| gcse.type = 'text/javascript'; |
| gcse.async = true; |
| gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + |
| '//www.google.com/cse/cse.js?cx=' + cx; |
| var s = document.getElementsByTagName('script')[0]; |
| s.parentNode.insertBefore(gcse, s); |
| })(); |
| </script><gcse:search></gcse:search></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 34. Reference Section</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="release-testing.html"><i class="icon-chevron-left"></i> Previous</a> </td><th width="60%" align="center">Part V. Reference Guide<br><a accesskey="p" href="index.html"><i class="icon-home"></i> Home</a></th><td width="20%" align="right"> <a accesskey="n" href="jetty-xml-usage.html">Next <i class="icon-chevron-right"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/">Contact the core Jetty developers at |
| <span class="website">www.webtide.com</span></a></h5><p> |
| private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... |
| scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery |
| </p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="reference-section"></a>Chapter 34. Reference Section</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="reference-section.html#jetty-xml-syntax">Jetty XML Syntax</a></span></dt><dt><span class="section"><a href="jetty-xml-usage.html">Jetty XML Usage</a></span></dt><dt><span class="section"><a href="jetty-xml-config.html"><code class="filename">jetty.xml</code></a></span></dt><dt><span class="section"><a href="jetty-web-xml-config.html"><code class="filename">jetty-web.xml</code></a></span></dt><dt><span class="section"><a href="jetty-env-xml.html"><code class="filename">jetty-env.xml</code></a></span></dt><dt><span class="section"><a href="webdefault-xml.html"><code class="filename">webdefault.xml</code></a></span></dt><dt><span class="section"><a href="override-web-xml.html">Jetty <code class="filename">override-web.xml</code></a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="jetty-xml-syntax"></a>Jetty XML Syntax</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="reference-section.html#basic-xml-configuration-file-eaxmple">Basic XML Configuration File Example</a></span></dt><dt><span class="section"><a href="reference-section.html#d0e24251">Overview</a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-configure"><Configure></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-set"><Set></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-get"><Get></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-put"><Put></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-call"><Call></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-arg"><Arg></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-new"><New></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-ref"><Ref></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-array"><Array></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-item"><Item></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-map"><Map></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-entry"><Entry></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-system-property"><SystemProperty></a></span></dt><dt><span class="section"><a href="reference-section.html#jetty-xml-property"><Property></a></span></dt></dl></div><p>The Jetty XML syntax is a straightforward mapping of XML elements to a |
| Java API so that POJOs can be instantiated and getters, setters, and methods |
| called. It is very similar to Inversion Of Control (IOC) or Dependency |
| Injection (DI) frameworks like Spring or Plexus (but it predates all of |
| them). Typically Jetty XML is used by <code class="filename">jetty.xml</code> to |
| configure a Jetty server or by a <code class="filename">context.xml</code> file to |
| configure a ContextHandler or subclass, but you can also use the mechanism |
| to configure arbitrary POJOs.</p><p>This page describes the basic syntax of Jetty XML configuration. See |
| <a class="link" href="jetty-xml-usage.html" title="Jetty XML Usage">Jetty XML Usage</a> for information on |
| how you can use and combine Jetty XML. See configuration files for specific |
| examples.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="basic-xml-configuration-file-eaxmple"></a>Basic XML Configuration File Example</h3></div></div></div><p>The following XML configuration file creates some Java objects and |
| sets some attributes:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> |
| <Configure id="foo" class="com.acme.Foo"> |
| <Set name="name">demo</Set> |
| <Set name="nested"> |
| <New id="bar" class="com.acme.Bar"> |
| <Arg>true</Arg> |
| <Set name="wibble">10</Set> |
| <Set name="wobble">xyz</Set> |
| <Set name="parent"><Ref refid="foo"/></Set> |
| <Call name="init"> |
| <Arg>false</Arg> |
| </Call> |
| </New> |
| </Set> |
| |
| <Ref refid="bar"> |
| <Set name="wibble">20</Set> |
| <Get name="parent"> |
| <Set name="name">demo2</Set> |
| </Get> |
| </Ref> |
| </Configure> ]]> |
| </script></div><p>The XML above is equivalent to the following Java code:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[com.acme.Foo foo = new com.acme.Foo(); |
| foo.setName("demo"); |
| |
| com.acme.Bar bar = new com.acme.Bar(true); |
| bar.setWibble(10); |
| bar.setWobble("xyz"); |
| bar.setParent(foo); |
| bar.init(false); |
| |
| foo.setNested(bar); |
| |
| bar.setWibble(20); |
| bar.getParent().setName("demo2"); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d0e24251"></a>Overview</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24254"></a>Understanding DTD and Parsing</h4></div></div></div><p>The document type descriptor (<a class="link" href="http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-xml/src/main/resources/org/eclipse/jetty/xml/configure_9_0.dtd?h=release-9" target="_top">configure.dtd</a>) |
| describes all valid elements in a Jetty XML configuration file using the |
| Jetty IoC format. The first two lines of an XML must reference the DTD |
| to be used to validate the XML like:</p><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| |
| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| ... |
| |
| ]]> |
| </script><p>Typcically a good XML editor will fetch the DTD from the URL and |
| use it to give syntax highlighting and validation while a configuration |
| file is being edited. Some editors also allows DTD files to be locally |
| cached. The URL may point to configure.dtd if you want the latest |
| current version, or to a specific version like configure_9_0.dtd if you |
| want a particular validation feature set.</p><p>Files that conform to the configure.dtd format are processed in |
| Jetty by the <code class="code"><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/xml/XmlConfiguration.html" target="_top">XmlConfiguration</a></code> |
| class which may also validate the XML (using a version of the DTD from |
| the classes jar file), but is by default run in a forgiving mode that |
| tries to work around validation failures.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24272"></a>Jetty XML Configuration Scope</h4></div></div></div><p>The configuration of object instances with Jetty IoC XML is done |
| on a scoped basis, so that for any given XML element there is a |
| corresponding Object in scope and the nested XML elements apply to that. |
| The outer most scope is given by a Configure element and elements like |
| Call, New and Get establish new scopes. The following example uses the |
| name fields to explain the scope</p><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[ |
| <Configure class="com.example.Foo"> |
| <Set name="fieldOnFoo">value</Set> |
| <Set name="fieldOnFoo"> |
| <New class="com.example.Bar"> |
| <Set name=fieldOnBar>value</Set> |
| <Call name="methodOnBarWithNoArgs"/> |
| </New> |
| </Set> |
| |
| <Call name="methodOnFoo"> |
| <Arg>value for first arg of methodOnFoo</Arg> |
| <Arg><New class="com.example.Bar"/></Arg> |
| <Set name="fieldOnObjectReturnedByMethodOnFoo">value</Set> |
| <Call name="methodOnObjectReturnedByMethodOnFooWithNoArgs"/> |
| </Call> |
| </Configure> |
| ]]> |
| </script></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24279"></a>Coercing Arguments to a Type</h4></div></div></div><p>When trying to match XML elements to java elements, Jetty |
| XmlConfiguration may need to coerces values to match method arguments. |
| By default it does so on a best effort basis, but you can also specify |
| explicit types with the <code class="literal">type</code> attribute. Supported |
| values for type are: String, Character, Short, Byte, Integer, Long, |
| Boolean, Float, Double, char, short, byte, int, long, boolean, float, |
| double, URL, InetAddress, InetAddrPort, void</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24287"></a>Referring to a Class</h4></div></div></div><p>If you do not specify the classname, Jetty assumes you are calling |
| the method on the object that is current in scope (eg the object of the |
| surrounding Configure, New or Get clause). If the class attribute is |
| specified to a fully-qualified class name, then it is either used to |
| create a new instance (Configure and New elements) or is used to access |
| a static (Call, Set or Get elements).</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24292"></a>Referring to an Object</h4></div></div></div><p>You can use the id attribute to store a reference to the current |
| object when first creating or referring to this object. You can then use |
| the <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a> to reference the |
| object later. The id must be unique for each object you create.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24300"></a>Attribute vs Element Style</h4></div></div></div><p>For XML elements that contain only other XML Elements, there is a |
| choice of using attributes or elements style. The following is an |
| example of attribute style:</p><script type="syntaxhighlighter" class="brush: plain;toolbar: false"> |
| <![CDATA[ <Call id="result" class="org.example.SomeClass" name="someMethod" arg="value0,value1"/>]]> |
| </script><p>Attribute style has the benefit of brevity, but is limited by: |
| values can only be Strings; multivalued items can not contain ','; |
| values may not be subject to property expansion or other elements that |
| return values. Thus the more verbose element style is available and the |
| following is semantically equivalent to the attribute style |
| above:</p><script type="syntaxhighlighter" class="brush: plain;toolbar: false"> |
| <![CDATA[ <Call> |
| <Id>result</Id> |
| <Class>org.example.SomeClass</Class> |
| <Name>someMethod</Name> |
| <Arg>value0</Arg> |
| <Arg>value1</Arg> |
| </Call>]]> |
| </script><p>Note that multivalued elements like Arg, must be repeated and may |
| not be comma separated like they are when provided as attributes. It is |
| possible to use a mix of styles and the following example shows a more |
| typical example that uses property expansion as the reason for element |
| style:</p><script type="syntaxhighlighter" class="brush: plain;toolbar: false"> |
| <![CDATA[ <Call id="result" name="someMethod"> |
| <Class><Property name="which.class"> |
| <Default><Property name="default.class" default="org.example.SomeClass"/> |
| </Property></Class> |
| <Arg>value0</Arg> |
| <Arg>value1</Arg> |
| </Call>]]> |
| </script><p>Attributes may not be expressed as elements when their parent |
| element is one that contains data. Thus Arg, Item, Set, Put and Get |
| elements may not have their attributes expressed as elements.</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-configure"></a><Configure></h3></div></div></div><p>This is the root element that specifies the class of object that is |
| to be configured. It is usually either the Server, in |
| <code class="code">jetty.xml</code>, or a WebAppContext in |
| <code class="code">jetty-web.xml</code>.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>id</td><td>no</td><td><p>A reference to the object that was created. If you |
| define multiple <a class="link" href="reference-section.html#jetty-xml-configure" title="<Configure>">Configure |
| element</a>s with the same id, they will be treated as one |
| object, even if they're in different files. You can use this to |
| break up configuration of an object (such as the Server) across |
| multiple files.</p></td></tr><tr><td>class</td><td>no</td><td>The fully qualified classname of the object to be |
| configured. Could be org.eclipse.jetty.server.Server, |
| org.eclipse.jetty.webapp.WebAppContext, a handler, etc.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24357"></a>Can Contain</h4></div></div></div><p><a class="link" href="reference-section.html#jetty-xml-set" title="<Set>">Set element</a>, <a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, <a class="link" href="reference-section.html#jetty-xml-put" title="<Put>">Put element</a>, <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24388"></a>Examples</h4></div></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24391"></a>Basic Example</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure class="org.eclipse.jetty.server.Server"> |
| <Set name="port">8080</Set> |
| </Configure> ]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(); |
| server.setPort(8080); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24402"></a>Using id to break up configuration of one object across |
| multiple files</h5></div></div></div><p>(etc/jetty.xml)</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="Server" class="org.eclipse.jetty.server.Server"> |
| <!-- basic configuration here --> |
| </Configure> ]]> |
| </script></div><p>(etc/jetty-logging.xml)</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="Server" class="org.eclipse.jetty.server.Server"> |
| <!-- assumes that you have the basic server configuration set up; this file only contains additional configuration for logging --> |
| </Configure> ]]> |
| </script></div><p>Then run the combined configuration using:</p><div class="screenexample"><pre class="screen">java -jar start.jar etc/jetty.xml jetty-logging.xml </pre></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-set"></a><Set></h3></div></div></div><p>A Set element maps to a call to a setter method or field on the |
| current object. It can contain text and/or elements such as Call, New, |
| SystemProperty, etc., as values. The name and optional type attributes are |
| used to select the setter method. If you do not specify a value type, |
| white space is trimmed out of the value. If it contains multiple elements |
| as values, they are added as strings before being converted to any |
| specified type.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>name</td><td>yes</td><td>the name of the setter method to call, or the field to set. |
| If the name given is xxx, then a setXxx method is used. If the |
| setXxx method cannot be found, then the xxx field is used.</td></tr><tr><td>type</td><td>no</td><td>the declared type of the argument. See also discussion of |
| type for Arg for how to define null and empty string |
| values.</td></tr><tr><td>class</td><td>no</td><td>if present, then this Set is treated as a static set method |
| invocation</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24456"></a>Can Contain</h4></div></div></div><p>value text, <a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, |
| <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-system-property" title="<SystemProperty>">System Property element</a>, |
| <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24485"></a>Examples</h4></div></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24488"></a>Basic Example</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="server" class="org.eclipse.jetty.server.Server"> |
| <Set name="port">8080</Set> |
| </Configure> ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24494"></a>Set via a System Property</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="server" class="org.eclipse.jetty.server.Server"> |
| <Set name="port"><SystemProperty name="jetty.http.port" /></Set> |
| </Configure> ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24500"></a>Creating a NewObject and Setting It on the Server</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="server" class="org.eclipse.jetty.server.Server"> |
| <Set name="threadPool"> |
| <New class="org.eclipse.jetty.util.thread.QueuedThreadPool"> |
| <Set name="minThreads">10</Set> |
| <Set name="maxThreads">1000</Set> |
| </New> |
| </Set> |
| </Configure> ]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(); |
| |
| org.eclipse.jetty.util.thread.QueuedThreadPool threadPool = new org.eclipse.jetty.util.thread.QueuedThreadPool(); |
| threadPool.setMinThreads(10); |
| threadPool.setMaxThreads(1000); |
| |
| server.setThreadPool(threadPool); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24511"></a>Invoking a Static Setter</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="server" class="org.eclipse.jetty.server.Server"> |
| <Set class="org.eclipse.jetty.util.log.Log" name="logToParent">loggerName</Set> |
| </Configure"> ]]> |
| </script></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-get"></a><Get></h3></div></div></div><p>A Get element maps to a call to a getter method or field on the |
| current object. It can contain nested elements such as Set, Put, Call, |
| etc.; these act on the object returned by the Get call.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>name</td><td>yes</td><td>the name of the getter method to call, or the field to get. |
| If the name given is xxx, then a getXxx method is used. If the |
| getXxx method cannot be found, then the xxx field is used.</td></tr><tr><td>class</td><td>no</td><td>f present, then this Get is treated as a static getter or |
| field.</td></tr><tr><td>id</td><td>no</td><td>if present, then you can use this id to refer to the |
| returned object later.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24554"></a>Can Contain</h4></div></div></div><p><a class="link" href="reference-section.html#jetty-xml-set" title="<Set>">Set element</a>, <a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, <a class="link" href="reference-section.html#jetty-xml-put" title="<Put>">Put element</a>, <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24585"></a>Examples</h4></div></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24588"></a>Basic Example</h5></div></div></div><p>This simple example doesn't do much on its own. You would |
| normally use this in conjunction with a <Ref id="Logger" |
| />.</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="server" class="org.eclipse.jetty.server.Server"> |
| <Get id="Logger" class="org.eclipse.jetty.util.log.Log" name="log"/> |
| </Configure> ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24596"></a>Invoking a Static Getter and Call Methods on the Returned |
| Object</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="server" class="org.eclipse.jetty.server.Server"> |
| <Get class="java.lang.System" name="out"> |
| <Call name="println"> |
| <Arg>Server version is: <Get class="org.eclipse.jetty.server.Server" name="version"/></Arg> |
| </Call> |
| </Get> |
| </Configure> ]]> |
| </script></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-put"></a><Put></h3></div></div></div><p>A Put element maps to a call to a put method on the current object, |
| which must implement the Map interface. It can contain text and/or |
| elements such as Call, New, SystemProperty, etc. as values. If you do not |
| specify a no value type, white space is trimmed out of the value. If it |
| contains multiple elements as values, they are added as strings before |
| being converted to any specified type.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>name</td><td>yes</td><td>used as the put key</td></tr><tr><td>type</td><td>no</td><td>forces the type of the value. See also discussion of type |
| for Arg for how to define null and empty string values.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24632"></a>Can Contain</h4></div></div></div><p>value text , <a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, |
| <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-system-property" title="<SystemProperty>">System Property element</a>, |
| <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24661"></a>Example</h4></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Get name="someKindOfMap"> |
| <Put name="keyName">objectValue</Put> |
| </Get> ]]> |
| </script></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-call"></a><Call></h3></div></div></div><p>A Call element maps to an arbitrary call to a method on the current |
| object. It can contain a sequence of Arg elements followed by a sequence |
| of configuration elements, such as Set, Put, Call. The <Arg>s are |
| passed as arguments to the method; the sequence of configuration elements |
| act on the object returned by the original call.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>name</td><td>yes</td><td>the name of the arbitrary method to call. The method called |
| will use the exact name you provide it.</td></tr><tr><td>class</td><td>no</td><td>if present, then this Call is treated as a static |
| method.</td></tr><tr><td>id</td><td>no</td><td>if present, you can use this id to refer to any object |
| returned by the call, for later use.</td></tr><tr><td>arg</td><td>no</td><td>comma separated list of arguments may be used for simple |
| string values rather than Arg elements</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24711"></a>Can Contain</h4></div></div></div><p>Attributes as elements (Id, Name, Class) plus <a class="link" href="reference-section.html#jetty-xml-arg" title="<Arg>">Arg element</a>, <a class="link" href="reference-section.html#jetty-xml-set" title="<Set>">Set element</a>, <a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, <a class="link" href="reference-section.html#jetty-xml-put" title="<Put>">Put element</a>, <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24746"></a>Examples</h4></div></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24749"></a>Basic example</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Call name="doFoo"> |
| <Arg>bar</Arg> |
| <Set name="test">1, 2, 3</Set> |
| </Call> ]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[Object o2 = o1.doFoo("bar"); |
| o2.setTest("1, 2, 3"); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24760"></a>Invoking a static method</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Call class="com.acme.Foo" name="setString"> |
| <Arg>somestring</Arg> |
| </Call> ]]> |
| </script></div><p>which is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[com.acme.Foo.setString("somestring"); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24771"></a>Invoking the Actual MethodInstead of Relying on Getter/Setter |
| Magic</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Configure id="Server" class="org.eclipse.jetty.server.Server"> |
| <Call name="getPort" id="port" /> |
| <Call class="com.acme.Environment" name="setPort"> |
| <Arg> |
| <Ref refid="port"/> |
| </Arg> |
| </Call> |
| </Configure> ]]> |
| </script></div><p>which is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[org.mortbay.jetty.Server server = new org.mortbay.jetty.Server(); |
| com.acme.Environment.setPort( server.getPort() ); ]]> |
| </script></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-arg"></a><Arg></h3></div></div></div><p>An Arg element can be an argument of either a method or a |
| constructor. Use it within <a class="xref" href="">???</a> and <a class="xref" href="">???</a>.</p><p>It can contain text and/or elements, such as Call, New, |
| SystemProperty, etc., as values. The optional type attribute can force the |
| type of the value. If you don't specify a type, white space is trimmed out |
| of the value. If it contains multiple elements as values, they are added |
| as strings before being converted to any specified type. Simple String |
| arguments can also be specified as a string separated arg attribute on the |
| parent element.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>type</td><td>no</td><td>force the type of the argument. If you do not provide a |
| value for the element, if you use type of "String", the value will |
| be the empty string (""), otherwise it is null.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24811"></a>Can Contain</h4></div></div></div><p>value text, <a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, |
| <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-system-property" title="<SystemProperty>">System Property element</a>, |
| <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24840"></a>Examples</h4></div></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24843"></a>Basic examples</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Arg>foo</Arg> <!-- String --> |
| <Arg>true</Arg> <!-- Boolean --> |
| <Arg>1</Arg> <!-- int, long, short, float, double --> |
| <Arg><Ref refid="foo" /></Arg> <!-- any object; reference a previously created object with id "foo", and pass it as a parameter --> |
| <Arg></Arg> <!-- null value --> |
| <Arg type="String"></Arg> <!-- empty string "" -> ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24849"></a>Coercing Type</h5></div></div></div><p>This explicitly coerces the type to a boolean:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Arg type="boolean">False</Arg> ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24857"></a>As a Parameter</h5></div></div></div><p>Here are a couple of examples of <a class="link" href="reference-section.html#jetty-xml-arg" title="<Arg>">Arg element</a> being used as a parameter |
| to methods and to constructors:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Call class="com.acme.Environment" name="setFoo"> |
| <Arg> |
| <New class="com.acme.Foo"> |
| <Arg>bar</Arg> |
| </New> |
| </Arg> |
| </Call> ]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[com.acme.Environment.setFoo(new com.acme.Foo("bar")); ]]> |
| </script></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<New class="com.acme.Baz"> |
| <Arg> |
| <Call id="bar" class="com.acme.MyStaticObjectFactory" name="createObject"> |
| <Arg>2</Arg> |
| </Call> |
| </Arg> |
| </New> ]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[new com.acme.Baz(com.acme.MyStaticObjectFactory.createObject(2)); ]]> |
| </script></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-new"></a><New></h3></div></div></div><p>Instantiates an object. Equivalent to new in Java, and allows the |
| creation of a new object. A New element can contain a sequence of <a class="link" href="reference-section.html#jetty-xml-arg" title="<Arg>">Arg element</a>'s, followed by a sequence of |
| configuration elements (Set, Put, etc). <a class="link" href="reference-section.html#jetty-xml-arg" title="<Arg>">Arg |
| element</a>'s are used to select a constructor for the object to be |
| created. The sequence of configuration elements then acts on the |
| newly-created object.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>class</td><td>yes</td><td>fully qualified classname, which determines the type of the |
| new object that is instantiated.</td></tr><tr><td>id</td><td>no</td><td>gives a unique name to the object which can be referenced |
| later by Ref elements.</td></tr><tr><td>arg</td><td>no</td><td>comma separated list of arguments may be used for simple |
| string values rather than Arg elements</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24924"></a>Can Contain</h4></div></div></div><p>Attributes as elements (Id, Class) plus <a class="link" href="reference-section.html#jetty-xml-arg" title="<Arg>">Arg element</a>, <a class="link" href="reference-section.html#jetty-xml-set" title="<Set>">Set element</a>, <a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, <a class="link" href="reference-section.html#jetty-xml-put" title="<Put>">Put element</a>, <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e24959"></a>Examples</h4></div></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24962"></a>Basic example</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<New class="com.acme.Foo"> |
| <Arg>bar</Arg> |
| </New> ]]> |
| </script></div><p>which is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[com.acme.Foo foo = new com.acme.Foo("bar"); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24973"></a>Instantiate with the Default Constructor</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<New class="com.acme.Foo" /> ]]> |
| </script></div><p>which is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[com.acme.Foo foo = new com.acme.Foo(); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e24984"></a>Instantiate with Multiple Arguments, Then Configuring |
| Further</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<New id="foo" class="com.acme.Foo"> |
| <Arg>bar</Arg> |
| <Arg>baz</Arg> |
| <Set name="test">1, 2, 3</Set> |
| </New> ]]> |
| </script></div><p>which is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[Object foo = new com.acme.Foo("bar", "baz"); |
| foo.setTest("1, 2, 3");]]> |
| </script></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-ref"></a><Ref></h3></div></div></div><p>A Ref element allows a previously created object to be referenced by |
| a unique id. It can contain a sequence of elements, such as Set or Put |
| which then act on the referenced object. You can also use a Ref element as |
| a value for other elements such as Set and Arg.</p><p>The Ref element provides convenience and eases readability. You can |
| usually achieve the effect of the Ref by nesting elements (method calls), |
| but this can get complicated very easily. The Ref element makes it |
| possible to refer to the same object if you're using it multiple times, or |
| passing it into multiple methods. It also makes it possible to split up |
| configuration across multiple files.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>refid</td><td>yes</td><td>the unique identifier used to name a previously created |
| object.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25020"></a>Can Contain</h4></div></div></div><p><a class="link" href="reference-section.html#jetty-xml-set" title="<Set>">Set element</a>, <a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, <a class="link" href="reference-section.html#jetty-xml-put" title="<Put>">Put element</a>, <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25051"></a>Examples</h4></div></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e25054"></a>Basic example</h5></div></div></div><p>Use the referenced object as an argument to a method call or |
| constructor:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Get id="foo" name="xFoo" /> |
| <Set name="test"><Ref refid="foo"/></Set> ]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[foo = getXFoo(); |
| setSomeMethod(foo); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e25067"></a>Manipulating the Object Returned by Ref</h5></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Get id="foo" name="xFoo" /> |
| <Ref refid="foo"> |
| <Set name="test">1, 2, 3</Set> |
| </Ref> ]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[foo = getXFoo(); |
| foo.setTest("1, 2, 3"); ]]> |
| </script></div></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e25078"></a>Ref vs. Nested Elements</h5></div></div></div><p>Here is an example of the difference in syntax between using the |
| Ref element, and nesting method calls. They are exactly |
| equivalent:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<!-- using Ref in conjunction with Get --> |
| <Configure id="Server" class="org.eclipse.jetty.server.Server"> |
| <Get id="Logger" class="org.eclipse.jetty.util.log.Log" name="log"/> |
| <Ref refid="Logger"> |
| <Set name="debugEnabled">true</Set> |
| </Ref> |
| </Configure> |
| <!-- calling the setter directly on the object returned by Get --> |
| <Configure id="Server" class="org.eclipse.jetty.server.Server"> |
| <Get class="org.eclipse.jetty.util.log.Log" name="log"> |
| <Set name="debugEnabled">true</Set> |
| </Get> |
| </Configure> ]]> |
| </script></div><p>Here is a more practical example, taken from the handler |
| configuration section in <code class="code"> etc/jetty.xml</code>:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Set name="handler"> |
| <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> |
| <Set name="handlers"> |
| <Array type="org.eclipse.jetty.server.Handler"> |
| <Item> |
| <!-- create a new instance of a ContextHandlerCollection named "Contexts" --> |
| <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/> |
| </Item> |
| <Item> |
| <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/> |
| </Item> |
| <Item> |
| <!-- create a new instance of a RequestLogHandler named "RequestLog" --> |
| <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/> |
| </Item> |
| </Array> |
| </Set> |
| </New> |
| </Set> |
| |
| <Call name="addBean"> |
| <Arg> |
| <New class="org.eclipse.jetty.deploy.ContextDeployer"> |
| <!-- pass in the ContextHandlerCollection object ("Contexts") that was created earlier, as an argument --> |
| <Set name="contexts"><Ref refid="Contexts"/></Set> |
| </New> |
| </Arg> |
| </Call> |
| |
| <!-- configure the RequestLogHandler object ("RequestLog") that we created earlier --> |
| <Ref refid="RequestLog"> |
| .... |
| </Ref> ]]> |
| </script></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-array"></a><Array></h3></div></div></div><p>An Array element allows the creation of a new array.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>type</td><td>no</td><td>specify what types of items the array can contain.</td></tr><tr><td>id</td><td>no</td><td>unique identifier you can use to refer to the array |
| later.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25124"></a>Can Contain</h4></div></div></div><p><a class="link" href="reference-section.html#jetty-xml-item" title="<Item>">Item element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25131"></a>Example</h4></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Array type="java.lang.String"> |
| <Item>value0</Item> |
| <Item><New class="java.lang.String"><Arg>value1</Arg></New></Item> |
| </Array>]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[String[] a = new String[] { "value0", new String("value1") }; ]]> |
| </script></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-item"></a><Item></h3></div></div></div><p>An Item element defines an entry for Array and Map elements.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>type</td><td>no</td><td>force the types of value.</td></tr><tr><td>id</td><td>no</td><td>unique identifier that you can use to refer to the array |
| later.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25172"></a>Can Contain</h4></div></div></div><p><a class="link" href="reference-section.html#jetty-xml-get" title="<Get>">Get element</a>, <a class="link" href="reference-section.html#jetty-xml-call" title="<Call>">Call element</a>, <a class="link" href="reference-section.html#jetty-xml-new" title="<New>">New element</a>, <a class="link" href="reference-section.html#jetty-xml-ref" title="<Ref>">Ref element</a>, <a class="link" href="reference-section.html#jetty-xml-array" title="<Array>">Array element</a>, <a class="link" href="reference-section.html#jetty-xml-map" title="<Map>">Map element</a>, <a class="link" href="reference-section.html#jetty-xml-system-property" title="<SystemProperty>">System Property element</a>, |
| <a class="link" href="reference-section.html#jetty-xml-property" title="<Property>">Property element</a></p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-map"></a><Map></h3></div></div></div><p>A Map element allows the creation of a new HashMap and to populate |
| it with (key, value) pairs.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>id</td><td>no</td><td>unique identifier you can use to refer to the map |
| later.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25223"></a>Can Contain</h4></div></div></div><p><a class="link" href="reference-section.html#jetty-xml-entry" title="<Entry>">Entry element</a></p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25229"></a>Example</h4></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Map> |
| <Entry> |
| <Item>keyName</Item> |
| <Item><New class="java.lang.String"><Arg>value1</Arg></New></Item> |
| </Entry> |
| </Map> ]]> |
| </script></div><p>This is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[Map m = new HashMap(); |
| m.put("keyName", new String("value1")); ]]> |
| </script></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-entry"></a><Entry></h3></div></div></div><p>An Entry element contains a key-value <a class="link" href="reference-section.html#jetty-xml-item" title="<Item>">Item element</a> pair for a Map.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25248"></a>Can Contain</h4></div></div></div><p><a class="link" href="reference-section.html#jetty-xml-item" title="<Item>">Item element</a></p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-system-property"></a><SystemProperty></h3></div></div></div><p>A SystemProperty element gets the value of a JVM system property. It |
| can be used within elements that accept values, such as Set, Put, |
| Arg.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>name</td><td>yes</td><td>property name</td></tr><tr><td>default</td><td>no</td><td>a default value as a fallback</td></tr><tr><td>id</td><td>no</td><td>unique identifier which you can use to refer to the array |
| later.</td></tr></tbody></table></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25291"></a>Can Contain</h4></div></div></div><p>Only attributes as Elements (Id, Name, Default).</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25296"></a>Example</h4></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<SystemProperty name="jetty.http.port" default="8080"/> ]]> |
| </script></div><p>That is equivalent to:</p><div class="informalexample"><script type="syntaxhighlighter" class="brush: java;toolbar: false"> |
| <![CDATA[System.getProperty("jetty.http.port", "8080"); ]]> |
| </script></div><p>Both try to retrieve the value of jetty.http.port. If jetty.http.port is not |
| set, then 8080 is used.</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="jetty-xml-property"></a><Property></h3></div></div></div><p>A Property element allows arbitrary properties to be retrieved by |
| name. It can contain a sequence of elements, such as Set, Put, Call that |
| act on the retrieved object.</p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th align="left">Attribute</th><th align="center">Required</th><th align="left">Description</th></tr></thead><tbody><tr><td>name</td><td>yes</td><td>property name</td></tr><tr><td>default</td><td>no</td><td>a default value as a fallback</td></tr><tr><td>id</td><td>no</td><td>unique identifier which you can use to refer to the array |
| later.</td></tr></tbody></table></div><p>The <code class="code">name</code> attribute may be a comma separated list of |
| property names, with the first property name being the "official" name, |
| and the others names being old, deprecated property names that are kept |
| for backward compatibility. A warning log is issued when deprecated |
| property names are used. The <code class="code">default</code> attribute contains the |
| value to use in case none of the property names is found.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25354"></a>Can Contain</h4></div></div></div><p>The attributes may be expressed as contained Elements (Id, Name, |
| Default).</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e25359"></a>Example</h4></div></div></div><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<Property name="Server"> |
| <Call id="jdbcIdMgr" name="getAttribute"> |
| <Arg>jdbcIdMgr</Arg> |
| </Call> |
| </Property> ]]> |
| </script></div></div></div></div></div><script type="text/javascript"> |
| SyntaxHighlighter.all() |
| </script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="release-testing.html"><i class="icon-chevron-left"></i> Previous</a> </td><td width="20%" align="center"><a accesskey="u" href="reference.html"><i class="icon-chevron-up"></i> Top</a></td><td width="40%" align="right"> <a accesskey="n" href="jetty-xml-usage.html">Next <i class="icon-chevron-right"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Testing a Jetty Release </td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="icon-home"></i> Home</a></td><td width="40%" align="right" valign="top"> Jetty XML Usage</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout"> |
| See an error or something missing? |
| <span class="callout"><a href="http://github.com/jetty-project/jetty-documentation">Contribute to this documentation at |
| <span class="website"><i class="icon-github"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2015-06-15T13:18:56-05:00)</i></span></div></p><script xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" type="text/javascript"> |
| var _gaq = _gaq || []; |
| _gaq.push(['_setAccount', 'UA-1149868-7']); |
| _gaq.push(['_trackPageview']); |
| |
| (function() { |
| var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
| ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
| var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
| })(); |
| </script></body></html> |