blob: 6e0586d60b8d7159f5dfc70fba642d159b0d4097 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Deployment Architecture</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="configuring-deployment.html" title="Chapter&nbsp;4.&nbsp;Deploying to Jetty"><link rel="prev" href="hot-deployment.html" title="Hot Deployment"><link rel="next" href="quickstart-webapp.html" title="Quickstart Webapps"><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">Deployment Architecture</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="hot-deployment.html"><i class="icon-chevron-left"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;4.&nbsp;Deploying to Jetty<br><a accesskey="p" href="index.html"><i class="icon-home"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="quickstart-webapp.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="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="deployment-architecture"></a>Deployment Architecture</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="deployment-architecture.html#udm-application-providers">Application Providers</a></span></dt><dt><span class="section"><a href="deployment-architecture.html#udm-application-lifecycle-graph">Application LifeCycle Graph</a></span></dt><dt><span class="section"><a href="deployment-architecture.html#udm-lifecycle-bindings">LifeCycle Bindings</a></span></dt><dt><span class="section"><a href="deployment-architecture.html#default-web-app-provider">Understanding the Default WebAppProvider</a></span></dt></dl></div><p>Jetty is built around an extensible Deployment Manager architecture
complete with formal LifeCycle for Web Applications going through it.</p><p>For Jetty to serve content (static or dynamic), you need to create a
<a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/handler/ContextHandler.html" target="_top">ContextHandler</a>
and add it to Jetty in the appropriate place. A pluggable DeploymentManager
exists in Jetty 7 and later to make this process easier. The Jetty
distribution contains example DeploymentManager configurations to deploy WAR
files found in a directory to Jetty, and to deploy Jetty
<code class="filename">context.xml</code> files into Jetty as well.</p><p>The DeploymentManager is the heart of the typical webapp deployment
mechanism; it operates as a combination of an Application LifeCycle Graph,
Application Providers that find and provide Applications into the
Application LifeCycle Graph, and a set of bindings in the graph that control
the deployment process.</p><div class="mediaobject" align="center"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0" width="195"><tr><td align="center"><img src="images/Jetty_DeployManager_DeploymentManager_Roles.png" align="middle" width="195"></td></tr></table></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="udm-application-providers"></a>Application Providers</h3></div></div></div><p>Before Jetty deploys an application, an <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/AppProvider.html" target="_top">
AppProvider</a> identifies the App and then provides it to the
DeploymentManager. The main AppProvider with the Jetty distribution is the
<a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/providers/WebAppProvider.html" target="_top">WebAppProvider.</a></p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="udm-application-lifecycle-graph"></a>Application LifeCycle Graph</h3></div></div></div><p>The core feature of the DeploymentManager is the <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/AppLifeCycle.html" target="_top">Application
LifeCycle Graph</a>.</p><div class="mediaobject" align="center"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0" width="340"><tr><td align="center"><img src="images/Jetty_DeployManager_AppLifeCycle-1.png" align="middle" width="340"></td></tr></table></div><p>The nodes and edges of this graph are pre-defined in Jetty along the
most common actions and states found. These nodes and edges are not
hardcoded; you can adjust and add to them depending on your needs (for
example, any complex requirements for added workflow, approvals, staging,
distribution, coordinated deploys for a cluster or cloud, etc.).</p><p>New applications enter this graph at the Undeployed node, and the
<a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/DeploymentManager.html#requestAppGoal(org.eclipse.jetty.deploy.App" target="_top">
<code class="code">java.lang.String DeploymentManager.requestAppGoal(App,String)</code>
</a> method pushes them through the graph.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="udm-lifecycle-bindings"></a>LifeCycle Bindings</h3></div></div></div><p>A set of default <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/AppLifeCycle.Binding.html" target="_top">
<code class="code">AppLifeCycle.Bindings</code> </a> defines standard behavior, and
handles deploying, starting, stopping, and undeploying applications. If
you choose, you can write your own <code class="code">AppLifeCycle.Bindings</code> and
assign them to anywhere on the Application LifeCycle graph.</p><p>Examples of new <code class="code">AppLifeCycle.Binding</code> implementations
that you can write include:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>Validating the incoming application.</p></li><li class="listitem"><p>Preventing the deployment of known forbidden
applications.</p></li><li class="listitem"><p>Submitting the installation to an application auditing service
in a corporate environment.</p></li><li class="listitem"><p>Distributing the application to other nodes in the cluster or
cloud.</p></li><li class="listitem"><p>Emailing owner/admin of change of state of the
application.</p></li></ul></div><p>There are four default bindings:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/StandardDeployer.html" target="_top">
StandardDeployer</a> &#8212; Deploys the ContextHandler into Jetty in the
appropriate place.</p></li><li class="listitem"><p><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/StandardStarter.html" target="_top">
StandardStarter</a> &#8212; Sets the ContextHandler to started and start
accepting incoming requests.</p></li><li class="listitem"><p><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/StandardStopper.html" target="_top">
StandardStopper</a> &#8212; Stops the ContextHandler and stops accepting
incoming requests.</p></li><li class="listitem"><p><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/StandardUndeployer.html" target="_top">
StandardUndeployer</a> &#8212; Removes the ContextHandler from
Jetty.</p></li></ul></div><div class="mediaobject" align="center"><table border="0" summary="manufactured viewport for HTML img" cellspacing="0" cellpadding="0" width="851"><tr><td align="center"><img src="images/Jetty_DeployManager_DefaultAppLifeCycleBindings.png" align="middle" width="851"></td></tr></table></div><p>A fifth, non-standard binding, called <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/bindings/DebugBinding.html" target="_top">Debug
Binding</a>, is also available for debugging reasons; It logs the
various transitions through the Application LifeCycle.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="default-web-app-provider"></a>Understanding the Default WebAppProvider</h3></div></div></div><p>The <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/deploy/providers/WebAppProvider.html" target="_top">WebAppProvider</a>
is for the deployment of Web Applications packaged as WAR files, expanded
as a directory, or declared in a <a class="xref" href="configuring-specific-webapp-deployment.html#deployable-descriptor-file" title="Jetty Deployable Descriptor XML File">Jetty Deployable Descriptor XML File</a>. It supports hot
(re)deployment.</p><p>The basic operation of the WebAppProvider is to periodically scan a
directory for deployables. In the standard Jetty Distribution, this is
configured in the <code class="filename">${jetty.home}/etc/jetty-deploy.xml</code>
file.</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_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.home" default="." />/webapps</Set>
<Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>
<Set name="scanInterval">1</Set>
<Set name="extractWars">true</Set>
</New>
</Arg>
</Call>
</New>
</Arg>
</Call>
</Configure> ]]>
</script></div><p>The above configuration will create a DeploymentManager tracked as a
Server LifeCycle Bean, with the following configuration.</p><div class="variablelist"><dl><dt><span class="term">contexts</span></dt><dd><p>A passed in reference to the HandlerContainer into which the
discovered webapps are deployed. This is normally a reference that
points to the <code class="literal">id="Contexts"</code> found in the
<code class="filename">${jetty.home}/etc/jetty.xml</code> file, which
itself is an instance of ContextHandlerCollection.</p></dd><dt><span class="term">monitoredDirName</span></dt><dd><p>Is a file path or URL to the directory to scan for web
applications.</p><p>Scanning follows these rules:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>Base directory must exist</p></li><li class="listitem"><p>Hidden Files (starting with <code class="filename">"."</code>)
are ignored</p></li><li class="listitem"><p>Directories with names ending in
<code class="filename">".d"</code> are ignored.</p></li><li class="listitem"><p>Common CVS directories <code class="filename">"CVS"</code> and
<code class="filename">"CVSROOT"</code> are ignored</p></li><li class="listitem"><p>Any <code class="filename">*.war</code> files are considered
<a class="link" href="automatic-webapp-deployment.html" title="Automatic Web Application Deployment">automatic
deployables</a></p></li><li class="listitem"><p>Any <code class="filename">*.xml</code> files are considered
<a class="link" href="configuring-specific-webapp-deployment.html#deployable-descriptor-file" title="Jetty Deployable Descriptor XML File">context descriptor
deployables</a></p></li><li class="listitem"><p>In the special case where both a WAR file and XML file
exists for same base name the XML file is assumed to configure
and reference the WAR file (see <a class="xref" href="configuring-specific-webapp-deployment.html" title="Configuring a Specific Web Application Deployment">Configuring a Specific Web Application Deployment</a>). Since
jetty-9.2.7, if either the WAR file or its corresponding XML
file changes, the webapp will be redeployed.</p></li><li class="listitem"><p>A directory is considered to be deployable</p></li><li class="listitem"><p>In the special case where both a Directory and WAR file
of the same name exists the WAR file is assumed to be an
automatic deployable.</p></li><li class="listitem"><p>In the special case where both a DIrectory and XML file
of the same name exists the XML file is assumed to configure
and reference the Directory.</p></li><li class="listitem"><p>All other directories are subject to automatic
deployment.</p></li><li class="listitem"><p>If automatic deployment is used, and the special
filename <code class="filename">root.war/ROOT.war</code> or directory
name <code class="filename">root/ROOT</code> will result in a
deployment to the <code class="literal">"/"</code> context path.</p></li></ol></div></dd><dt><span class="term">defaultsDescriptor</span></dt><dd><p>Specifies the default Servlet web descriptor to use for all
Web Applications. The intent of this descriptor is to include
common configuration for the Web Application before the Web
Application's own <code class="filename">/WEB-INF/web.xml</code> is
applied. The <code class="filename">${jetty.home}/etc/webdefault.xml</code>
that comes with the Jetty distribution controls the configuration
of the JSP and Default servlets, along with mimetypes and other
basic metadata.</p></dd><dt><span class="term">scanInterval</span></dt><dd><p>Is the period in seconds between sweeps of the
<code class="literal">monitoredDirName</code> for changes: new contexts to
deploy, changed contexts to redeploy, or removed contexts to
undeploy.</p></dd><dt><span class="term">extractWars</span></dt><dd><p>If parameter is true, any packed WAR or zip files are first
extracted to a temporary directory before being deployed. This is
advisable if there are uncompiled JSPs in the web apps.</p></dd><dt><span class="term">parentLoaderPriority</span></dt><dd><p>parameter is a boolean that selects whether the standard
Java <a class="link" href="jetty-classloading.html" title="Jetty Classloading">parent first
delegation</a> is used or the <a class="link" href="jetty-classloading.html" title="Jetty Classloading">servlet specification webapp
classloading priority</a>. The latter is the default.</p></dd></dl></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="hot-deployment.html"><i class="icon-chevron-left"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="configuring-deployment.html"><i class="icon-chevron-up"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="quickstart-webapp.html">Next <i class="icon-chevron-right"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Hot Deployment&nbsp;</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">&nbsp;Quickstart Webapps</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:15-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>