| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Deployment Processing of WebAppContexts</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.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"><link rel="up" href="configuring-deployment.html" title="Chapter 4. Deploying to Jetty"><link rel="prev" href="configuring-specific-webapp-deployment.html" title="Configuring a Specific Web Application Deployment"><link rel="next" href="static-content-deployment.html" title="Configuring Static Content Deployment"><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"><link rel="stylesheet" href="css/highlighter/foundation.css"><script src="js/highlight.pack.js"></script><script> |
| hljs.initHighlightingOnLoad(); |
| </script><link type="text/css" rel="stylesheet" href="css/font-awesome/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.28.v20191105</span></td><td style="width: 50%"></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">Deployment Processing of WebAppContexts</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="configuring-specific-webapp-deployment.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a> </td><th width="60%" align="center">Chapter 4. Deploying to Jetty<br><a accesskey="p" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></th><td width="20%" align="right"> <a accesskey="n" href="static-content-deployment.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></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 for sponsored feature development |
| </p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="configuring-webapps"></a>Deployment Processing of WebAppContexts</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="configuring-webapps.html#webapp-configurations">Configuration Classes</a></span></dt><dt><span class="section"><a href="configuring-webapps.html#webapp-context-attributes">Other Configuration</a></span></dt></dl></div><p>Web applications require a certain amount of processing before they can go into service: they may need to be unpacked, a special classloader created for their jar files, <code class="literal">web.xml</code> and <code class="literal">web-fragment.xml</code> descriptors processed, and classes scanned for annotations amongst other things. |
| As web applications have become more complex, Jetty has added ways to assist with customization by either broadening or lessening the amount of processing that is done at deployment time. |
| This section will examine this processing and it can be tailored to fit individual needs.</p><p>If instead you’re looking for information on how to configure a specific <code class="literal">WebAppContext</code> - such as its context path, whether it should be unpacked or not - then you can find that in the section entitled <a class="link" href="configuring-specific-webapp-deployment.html" title="Configuring a Specific Web Application Deployment">Configuring a Specific WebApp Deployment</a>.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="webapp-configurations"></a>Configuration Classes</h3></div></div></div><p>As a webapp is being deployed, a series of <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/Configuration.html" target="_top">org.eclipse.jetty.webapp.Configuration</a> classes are applied to it, each one performing a specific function. |
| The ordering of these Configurations is significant as subsequent Configurations tend to build on information extracted or setup in foregoing Configurations. |
| These are the default list, in order, of Configurations that are applied to each <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/WebAppContext.html" target="_top">org.eclipse.jetty.webapp.WebAppContex</a>t:</p><div class="table"><a name="d0e2811"></a><p class="title"><b>Table 4.1. Default Configuration classes</b></p><div class="table-contents"><table class="table" summary="Default Configuration classes" border="1"><colgroup><col class="col_1"><col class="col_2"></colgroup><tbody><tr><td align="left" valign="top"><p><a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/WebInfConfiguration.html" target="_top">org.eclipse.jetty.webapp.WebInfConfiguration</a></p></td><td align="left" valign="top"><p>Extracts war, orders jars and defines classpath</p></td></tr><tr><td align="left" valign="top"><p><a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/WebXmlConfiguration.html" target="_top">org.eclipse.jetty.webapp.WebXmlConfiguration</a></p></td><td align="left" valign="top"><p>Processes a WEB-INF/web.xml file</p></td></tr><tr><td align="left" valign="top"><p><a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/MetaInfConfiguration.html" target="_top">org.eclipse.jetty.webapp.MetaInfConfiguration</a></p></td><td align="left" valign="top"><p>Looks in container and webapp jars for META-INF/resources and |
| META-INF/web-fragment.xml</p></td></tr><tr><td align="left" valign="top"><p><a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/FragmentConfiguration.html" target="_top">org.eclipse.jetty.webapp.FragmentConfiguration</a></p></td><td align="left" valign="top"><p>Processes all discovered META-INF/web-fragment.xml files</p></td></tr><tr><td align="left" valign="top"><p><a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.html" target="_top">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</a></p></td><td align="left" valign="top"><p>Processes a WEB-INF/jetty-web.xml file</p></td></tr></tbody></table></div></div><br class="table-break"><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="_anatomy_of_a_configuration_class"></a>Anatomy of a Configuration Class</h4></div></div></div><p>A Configuration class is called 5 times in different phases of the <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/WebAppContext.html" target="_top"><code class="literal">WebAppContext's</code></a> lifecycle:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">preConfigure</span></dt><dd>As the <code class="literal">WebAppContext</code> is starting up this phase is executed. |
| The <code class="literal">Configuration</code> should discover any of the resources it will need during the subsequent phases.</dd><dt><span class="term">configure</span></dt><dd>This phase is where the work of the class is done, usually using the resources discovered during the <code class="literal">preConfigure</code> phase.</dd><dt><span class="term">postConfigure</span></dt><dd>This phase allows the <code class="literal">Configuration</code> to clear down any resources that may have been created during the previous 2 phases that are not needed for the lifetime of the <code class="literal">WebAppContext</code>.</dd><dt><span class="term">deconfigure</span></dt><dd>This phase occurs whenever a <code class="literal">WebAppContext</code> is being stopped and allows the Configuration to undo any resources/metadata that it created. |
| A <code class="literal">WebAppContext</code> should be able to be cleanly start/stopped multiple times without resources being held.</dd><dt><span class="term">destroy</span></dt><dd>This phase is called when a <code class="literal">WebAppContext</code> is actually removed from service. |
| For example, the war file associated with it is deleted from the $JETTY_HOME/webapps directory.</dd></dl></div><p>Each phase is called on each <code class="literal">Configuration</code> class in the order in which the <code class="literal">Configuration</code> class is listed. |
| Using the default <code class="literal">Configuration</code> classes as an example, <code class="literal">preConfigure()</code> will be called on <code class="literal">WebInfConfiguration</code>, <code class="literal">WebXmlConfiguration</code>, <code class="literal">MetaInfConfiguration</code>, <code class="literal">FragmentConfiguration</code> and then <code class="literal">JettyWebXmlConfiguration</code>. |
| The cycle begins again for the <code class="literal">configure()</code> phase and again for the <code class="literal">postConfigure()</code> phases. |
| The cycle is repeated <span class="emphasis"><em>in reverse order</em></span> for the <code class="literal">deconfigure()</code> and eventually the <code class="literal">destroy()</code> phases.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="_extending_container_support_by_creating_extra_configurations"></a>Extending Container Support by Creating Extra Configurations</h4></div></div></div><p>As shown, there is a default set of Configurations that support basic deployment of a webapp. |
| JavaEE features such as JNDI and advanced servlet spec features such as annotations have not been mentioned. |
| Jetty’s philosophy is to allow the user to tailor the container exactly to their needs. |
| If these features are not needed, then Jetty does not pay the price for them - an important consideration because features such as annotations require extensive and time-consuming scanning of <code class="literal">WEB-INF/lib</code> jars. |
| As modern webapps may have scores of these jars, it can be a source of significant deployment delay. |
| We will see in the section <a class="link" href="configuring-webapps.html#webapp-context-attributes" title="Other Configuration">Other Configuration</a> another helpful webapp facility that Jetty provides for cutting down the time spent analyzing jars.</p><p>Jetty makes use of the flexibility of Configurations to make JNDI and annotation support pluggable.</p><p>Firstly, lets look at how Configurations help enable JNDI.</p><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="jndi-configuration-classes"></a>Example: JNDI Configurations</h5></div></div></div><p>JNDI lookups within web applications require the container to hookup resources defined in the container’s environment to that of the web application. |
| To achieve that, we use 2 extra Configurations:</p><div class="table"><a name="d0e2986"></a><p class="title"><b>Table 4.2. JNDI Configuration classes</b></p><div class="table-contents"><table class="table" summary="JNDI Configuration classes" border="1"><colgroup><col class="col_1"><col class="col_2"></colgroup><tbody><tr><td align="left" valign="top"><p><a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/plus/webapp/EnvConfiguration.html" target="_top">org.eclipse.jetty.plus.webapp.EnvConfiguration</a></p></td><td align="left" valign="top"><p>Creates <code class="literal">java:comp/env</code> for the webapp, applies a <code class="literal">WEB-INF/jetty-env.xml</code> file</p></td></tr><tr><td align="left" valign="top"><p><a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/plus/webapp/PlusConfiguration.html" target="_top">org.eclipse.jetty.plus.webapp.PlusConfiguration</a></p></td><td align="left" valign="top"><p>Processes JNDI related aspects of <code class="literal">WEB-INF/web.xml</code> and hooks up naming entries</p></td></tr></tbody></table></div></div><br class="table-break"><p>These configurations must be added in <span class="emphasis"><em>exactly</em></span> the order shown above and should be inserted <span class="emphasis"><em>immediately before</em></span> the <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.html" target="_top">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</a> class in the list of configurations. |
| To fully support JNDI additional configuration is required, full details of which can be found <a class="link" href="jndi.html" title="Chapter 12. Configuring JNDI">here</a>.</p></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="_example_annotation_configurations"></a>Example: Annotation Configurations</h5></div></div></div><p>We need just one extra Configuration class to help provide servlet annotation scanning:</p><div class="table"><a name="d0e3037"></a><p class="title"><b>Table 4.3. Annotation Configuration classes</b></p><div class="table-contents"><table class="table" summary="Annotation Configuration classes" border="1"><colgroup><col class="col_1"><col class="col_2"></colgroup><tbody><tr><td align="left" valign="top"><p><a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/annotations.AnnotationConfiguration.html" target="_top">org.eclipse.jetty.annotations.AnnotationConfiguration</a></p></td><td align="left" valign="top"><p>Scan container and web app jars looking for @WebServlet, @WebFilter, |
| @WebListener etc</p></td></tr></tbody></table></div></div><br class="table-break"><p>The above configuration class must be <span class="emphasis"><em>inserted immediately before</em></span> the <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.html" target="_top">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</a> class in the list of configurations. |
| To fully support annotations additional configuration is require, details of which can be found <a class="link" href="configuring-webapps.html#webapp-context-attributes" title="Other Configuration">below.</a></p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="_how_to_set_the_list_of_configurations"></a>How to Set the List of Configurations</h4></div></div></div><p>You have a number of options for how to make Jetty use a different list of Configurations.</p><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="_setting_the_list_directly_on_the_webappcontext"></a>Setting the list directly on the WebAppContext</h5></div></div></div><p>If you have only one webapp that you wish to affect, this may be the easiest option. |
| You will, however, either need to have a context xml file that represents your web app, or you need to call the equivalent in code. |
| Let’s see an example of how we would add in the Configurations for both JNDI <span class="emphasis"><em>and</em></span> annotations:</p><pre 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"><code><?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <Configure class="org.eclipse.jetty.webapp.WebAppContext"> |
| |
| <Set name="war"><SystemProperty name="jetty.base" default="."/>/webapps/my-cool-webapp</Set> |
| |
| <Set name="configurationClasses"> |
| <Array type="java.lang.String"> |
| <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item> |
| <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item> |
| </Array> |
| </Set> |
| |
| </Configure></code></pre><p>Of course, you can also use this method to reduce the Configurations applied to a specific <code class="literal">WebAppContext</code>.</p></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="_setting_the_list_for_all_webapps_via_the_deployer"></a>Setting the list for all webapps via the Deployer</h5></div></div></div><p>If you use the <a class="link" href="deployment-architecture.html" title="Deployment Architecture">deployer</a>, you can set up the list of Configuration classes on the <a class="link" href="deployment-architecture.html#default-web-app-provider" title="Understanding the Default WebAppProvider">WebAppProvider</a>. |
| They will then be applied to each <code class="literal">WebAppContext</code> deployed by the deployer:</p><pre 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"><code><?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <Configure id="Server" class="org.eclipse.jetty.server.Server"> |
| |
| <Call name="addBean"> |
| <Arg> |
| <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager"> |
| <Set name="contexts"> |
| <Ref refid="Contexts" /> |
| </Set> |
| <Call id="webappprovider" name="addAppProvider"> |
| <Arg> |
| <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"> |
| <Set name="monitoredDirName"><Property name="jetty.base" default="." />/webapps</Set> |
| <Set name="configurationClasses"> |
| <Array type="java.lang.String"> |
| <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item> |
| <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item> |
| </Array> |
| </Set> |
| </New> |
| </Arg> |
| </Call> |
| </New> |
| </Arg> |
| </Call> |
| </Configure></code></pre></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="_adding_or_inserting_to_an_existing_list"></a>Adding or inserting to an existing list</h5></div></div></div><p>Instead of having to enumerate the list in its entirety, you can simply nominate classes that you want to add, and indicate whereabouts in the list you want them inserted. |
| Let’s look at an example of using this method to add in Configuration support for JNDI - as usual you can either do this in an xml file, or via equivalent code. |
| This example uses an xml file, in fact it is the <code class="literal">$JETTY_HOME/etc/jetty-plus.xml</code> file from the Jetty distribution:</p><pre 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"><code><?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <Configure id="Server" class="org.eclipse.jetty.server.Server"> |
| |
| <!-- =========================================================== --> |
| <!-- Add plus Configuring classes to all webapps for this Server --> |
| <!-- =========================================================== --> |
| <Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault"> |
| <Arg><Ref refid="Server" /></Arg> |
| <Call name="addAfter"> |
| <Arg name="afterClass">org.eclipse.jetty.webapp.FragmentConfiguration</Arg> |
| <Arg> |
| <Array type="String"> |
| <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item> |
| </Array> |
| </Arg> |
| </Call> |
| </Call> |
| |
| </Configure></code></pre><p>The <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/Configuration.html" target="_top">org.eclipse.jetty.webapp.Configuration.ClassList</a> class provides these methods for insertion:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">addAfter</span></dt><dd>Inserts the supplied list of <code class="literal">Configuration</code> class names after the given Configuration class name.</dd><dt><span class="term">addBefore</span></dt><dd>Inserts the supplied list of <code class="literal">Configuration</code> class names before the given Configuration class name.</dd></dl></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="webapp-context-attributes"></a>Other Configuration</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="container-include-jar-pattern"></a>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</h4></div></div></div><p>This is a context attribute that can be set on <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.3.28.v20191105/org/eclipse/jetty/webapp/WebAppContext.html" target="_top">an org.eclipse.jetty.webapp.WebAppContext</a> to control which parts of the <span class="emphasis"><em>container’s</em></span> classpath should be processed for things like annotations, <code class="literal">META-INF/resources</code>, <code class="literal">META-INF/web-fragment.xml</code> and <code class="literal">tlds</code> inside <code class="literal">META-INF</code>.</p><p>Normally, nothing from the container classpath will be included for processing. |
| However, sometimes you will need to include some. |
| For example, you may have some libraries that are shared amongst your webapps and thus you have put them into a <code class="literal">$JETTY_HOME/lib</code> directory. |
| The libraries contain annotations and therefore must be scanned.</p><p>The value of this attribute is a regexp that defines which <span class="emphasis"><em>jars</em></span> and <span class="emphasis"><em>class directories</em></span> from the container’s classpath should be examined.</p><p>Here’s an example from a context xml file (although as always, you could have accomplished the same in code), which would match any jar whose name starts with "foo-" or "bar-", or a directory named "classes":</p><pre 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"><code><?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <Configure class="org.eclipse.jetty.webapp.WebAppContext"> |
| |
| <Call name="setAttribute"> |
| <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg> |
| <Arg>.*/foo-[^/]*\.jar$|.*/bar-[^/]*\.jar$|.*/classes/.*</Arg> |
| </Call> |
| |
| </Configure></code></pre><p>Note that the order of the patterns defines the ordering of the scanning of the jars or class directories.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="web-inf-include-jar-pattern"></a>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</h4></div></div></div><p>Similarly to the previous context attribute, this attribute controls which jars are processed for things like annotations, <code class="literal">META-INF/resources</code>, <code class="literal">META-INF/web-fragment.xml</code> and <code class="literal">tlds</code> in <code class="literal">META-INF</code>. |
| However, this attribute controls which jars from the <span class="emphasis"><em>webapp’s</em></span> classpath (usually <code class="literal">WEB-INF/lib</code>) are processed. |
| This can be particularly useful when you have dozens of jars in <code class="literal">WEB-INF/lib</code>, but you know that only a few need to be scanned.</p><p>Here’s an example in a xml file of a pattern that matches any jar that starts with <code class="literal">spring-</code>:</p><pre 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"><code><?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <Configure class="org.eclipse.jetty.webapp.WebAppContext"> |
| |
| <Call name="setAttribute"> |
| <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg> |
| <Arg>.*/spring-[^/]*\.jar$</Arg> |
| </Call> |
| |
| </Configure></code></pre><p>Note that the order of the patterns defines the ordering of the scanning of jar files.</p></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="configuring-specific-webapp-deployment.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a> </td><td width="20%" align="center"><a accesskey="u" href="configuring-deployment.html"><i class="fa fa-chevron-up" aria-hidden="true"></i> Top</a></td><td width="40%" align="right"> <a accesskey="n" href="static-content-deployment.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Configuring a Specific Web Application Deployment </td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></td><td width="40%" align="right" valign="top"> Configuring Static Content Deployment</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/eclipse/jetty.project">Contribute to this documentation at |
| <span class="website"><i class="fa fa-github" aria-hidden="true"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2019-11-05)</i></span></div></p></body></html> |