Jump to: navigation, search

Jetty/Feature/WebAppProvider

< Jetty‎ | Feature
Revision as of 18:54, 18 June 2010 by Michael.webtide.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



Introduction

The WebAppDeployer 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 Context Deployer.

Feature

The basic operation of WebAppDeployer is to scan a directory at startup for WAR files or webapp directories and the deploy the webapplications found. Typically this is done from a jetty.xml file:

 <Call name="addLifeCycle">
   <Arg>
     <New class="org.mortbay.jetty.deployer.WebAppDeployer">
       <Set name="contexts"><Ref id="Contexts"/></Set>
       <Set name="webAppDir"><SystemProperty name="jetty.home" default<nowiki>=</nowiki>"."/>/webapps</Set>
       <Set name="parentLoaderPriority">false</Set>
       <Set name="extract">true</Set>
       <Set name="allowDuplicates">false</Set>
       <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default<nowiki>=</nowiki>"."/>/etc/webdefault.xml</Set>
     </New>
   </Arg>
 </Call>

The WebAppDeployer is added to the server as a LifeCycle. This simply means that the deployer will be started and stopped with the server. Ie when server.start() is called, then start will also be called on the deployer.

The context passed in is a reference to a HandlerContainer in which the discovered webapps will be deployed. This is normally an instance of ContextHandlerCollection.

The webAppDir is a file path or URL to the directory to scan for webapplications. Zip files ending with .war or .zip are deployed. Directories not call CVS are also deployed. The basename of the war (eg 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 of the standard java parent first delegation classloading will be used or the servlet specification webapp classloading priority.

If the extract parameter is true, any packed war or zip files will first be extracted to a temporary directory before being deployed. This is advisable if there are uncompiled JSPs in the web apps.

If the allowDuplicates parameter is false, the discovered webapps will be checked against existing deployed webapps and will not be deployed if the same context path or war files is already deployed (perhaps by another deployer).

The defaultsDescriptor parameter allows an alternative webdefault.xml config file to be set on the discovered web applications. The webdefault.xml file is used to control the configuration of the JSP and Default servlets.