Jetty Logo
Version: 9.2.2-SNAPSHOT
Contact the core Jetty developers at www.webtide.com

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

Deployment Architecture

Application Providers
Application LifeCycle Graph
LifeCycle Bindings
Understanding the Default WebAppProvider

Jetty is built around an extensible Deployment Manager architecture complete with formal LifeCycle for Web Applications going through it.

For Jetty to serve content (static or dynamic), you need to create a ContextHandler 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 context.xml files into Jetty as well.

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.

Application Providers

Before Jetty deploys an application, an AppProvider identifies the App and then provides it to the DeploymentManager. The main AppProvider with the Jetty distribution is the WebAppProvider.

Application LifeCycle Graph

The core feature of the DeploymentManager is the Application LifeCycle Graph.

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.).

New applications enter this graph at the Undeployed node, and the java.lang.String DeploymentManager.requestAppGoal(App,String) method pushes them through the graph.

LifeCycle Bindings

A set of default AppLifeCycle.Bindings defines standard behavior, and handles deploying, starting, stopping, and undeploying applications. If you choose, you can write your own AppLifeCycle.Bindings and assign them to anywhere on the Application LifeCycle graph.

Examples of new AppLifeCycle.Binding implementations that you can write include:

  • Validating the incoming application.

  • Preventing the deployment of known forbidden applications.

  • Submitting the installation to an application auditing service in a corporate environment.

  • Distributing the application to other nodes in the cluster or cloud.

  • Emailing owner/admin of change of state of the application.

There are four default bindings:

  • StandardDeployer –Deploys the ContextHandler into Jetty in the appropriate place.

  • StandardStarter –Sets the ContextHandler to started and start accepting incoming requests.

  • StandardStopper –Stops the ContextHandler and stops accepting incoming requests.

  • StandardUndeployer –Removes the ContextHandler from Jetty.

A fifth, non-standard binding, called Debug Binding, is also available for debugging reasons; It logs the various transitions through the Application LifeCycle.

Understanding the Default WebAppProvider

The WebAppProvider is for the deployment of Web Applications packaged as WAR files, expanded as a directory, or declared in a Jetty Deployable Descriptor XML File. It supports hot (re)deployment.

The basic operation of the WebAppProvider is to periodically scan a directory for deployables. In the standard Jetty Distribution, this is configured in the ${jetty.home}/etc/jetty-deploy.xml file.

The above configuration will create a DeploymentManager tracked as a Server LifeCycle Bean, with the following configuration.

contexts

A passed in reference to the HandlerContainer into which the discovered webapps are deployed. This is normally a reference that points to the id="Contexts" found in the ${jetty.home}/etc/jetty.xml file, which itself is an instance of ContextHandlerCollection.

monitoredDirName

Is a file path or URL to the directory to scan for web applications.

Scanning follows these rules:

  1. Base directory must exist

  2. Hidden Files (starting with ".") are ignored

  3. Directories with names ending in ".d" are ignored.

  4. Common CVS directories "CVS" and "CVSROOT" are ignored

  5. Any *.war files are considered automatic deployables

  6. Any *.xml files are considered context descriptor deployables

  7. In the special case where both a WAR file and XML file exists for same base name, then the WAR file is flagged as not-deployable, and the XML file is assumed to configure and reference the WAR file. (see Configuring a Specific Web Application Deployment)

  8. And directory is considered to be deployable

  9. In the special case where both a Directory and WAR file of the same name exists, the directory is flagged as not-deployable, and the WAR file is assumed to be and automatic deployable.

  10. In the special case where both a DIrectory and XML file of the same name exists, the directory is flagged as not-deployable, and the XML file is assumed to configure and reference the Directory.

  11. All other directories are subject to automatic deployment.

  12. If automatic deployment is used, and the special filename root.war or directory name root will result in a deployment to the "/" context path.

defaultsDescriptor

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 /WEB-INF/web.xml is applied. The ${jetty.home}/etc/webdefault.xml that comes with the Jetty distribution controls the configuration of the JSP and Default servlets, along with mimetypes and other basic metadata.

scanInterval

Is the period in seconds between sweeps of the monitoredDirName for changes: new contexts to deploy, changed contexts to redeploy, or removed contexts to undeploy.

extractWars

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.

parentLoaderPriority

parameter is a boolean that selects whether the standard Java parent first delegation is used or the servlet specification webapp classloading priority. The latter is the default.

See an error or something missing? Contribute to this documentation at Github!(Generated: 2014-09-14T01:00:23-07:00)