The
WebApp Provider
is for static deployment of standard WAR files and webapps with little or no Jetty-specific customization.
For hot deployment of customized contexts, use the
ContextProvider
.
The basic operation of the WebAppProvider
is to scan a directory at startup for WAR files or
webapp directories and to deploy the web applications found. Typically this is done from a
jetty.xml
style file; in the jetty distribution the name of this file is
jetty-webapps.xml
:
<Configure id="Server" class="org.eclipse.jetty.server.Server"> <Ref id="DeploymentManager"> <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="contextXmlDir"><Property name="jetty.home" default="." />/contexts</Set> <Set name="extractWars">true</Set> </New> </Arg> </Call> </Ref> </Configure>
This works as follows:
The WebAppProvider
is added to the server as a LifeCycle. This simply
means that the deployer starts and stops with the server, that is, when server.start()
is called,
start
is also called on the deployer
The context passed in is a reference to a HandlerContainer
in which the
discovered webapps are deployed. This is normally an instance of
ContextHandlerCollection.
The contextXmlDir
points to a directory like the one the ContextProvider
uses.
When you use this option the WebappProvider
checks any webapp or WAR files in the monitored
directory for an associated context file. If it finds one, it defers to the ContextProvider
to
deploy the webapp. If it does not find a context file, the WebAppProvider
deploys the webapp.
The monitoredDirName
is a file path or URL to the directory to scan for web applications. Zip
files ending with .war
or .zip
are deployed. Directories not called CVS
are also deployed. The basename of the WAR (for example, foo from
foo.war
) or the directory name are used as the context path of the discovered webapps, unless the name
is root, in which case the context path of / is used.
The parentLoaderPriority
parameter is a boolean that selects whether the standard Java parent
first delegation [[Jetty/Reference/Jetty_Classloading|classloading]] // TODO URL xref / /is used or the servlet
specification webapp classloading priority.
If the extract parameter is true, any packed WAR or zip files are first extracted to a [[Jetty/Reference/Temporary_Directories|temporary directory]] //TODO xref// before being deployed. This is advisable if there are uncompiled JSPs in the web apps.
If the allowDuplicates parameter is false, the discovered webapps are checked against existing deployed webapps and are not deployed if the same context path or WAR file is already deployed (perhaps by another deployer).
The defaultsDescriptor parameter allows you to set an alternative
webdefault.xml
config file on the discovered web applications. The webdefault.xml
file
controls the configuration of the JSP and Default servlets.