Jump to: navigation, search

Difference between revisions of "Jetty/Feature/WebAppProvider"

< Jetty‎ | Feature
Line 1: Line 1:
 
{{Jetty Feature
 
{{Jetty Feature
 
| introduction =
 
| introduction =
{{warning|Deprecated:|WebAppDeployer has been superseded by the new Deployment Manager module.}}
+
The [http://dev.eclipse.org/viewcvs/index.cgi/jetty/trunk/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/providers/WebAppProvider.java?root=RT_JETTY&view=markup WebAppProvider] 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 [[Jetty/Feature/ContextDeployer|Context Provider]].
The [http://dev.eclipse.org/viewcvs/index.cgi/jetty/trunk/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppDeployer.java?root=RT_JETTY&view=markup 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 [[Jetty/Feature/ContextDeployer|Context Deployer]].
+
 
| body =  
 
| body =  
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:
+
The basic operation of WebAppProvider 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 style file, in the jetty distribution this file is called jetty-webapps.xml:
 
<source lang="xml">
 
<source lang="xml">
  <Call name="addLifeCycle">
+
  <Configure id="Server" class="org.eclipse.jetty.server.Server">
  <Arg>
+
    <Ref id="DeploymentManager">
    <New class="org.mortbay.jetty.deployer.WebAppDeployer">
+
          <Call id="webappprovider" name="addAppProvider">
      <Set name="contexts"><Ref id="Contexts"/></Set>
+
            <Arg>
      <Set name="webAppDir"><SystemProperty name="jetty.home" default<nowiki>=</nowiki>"."/>/webapps</Set>
+
              <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
      <Set name="parentLoaderPriority">false</Set>
+
                <Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
      <Set name="extract">true</Set>
+
                <Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
      <Set name="allowDuplicates">false</Set>
+
                <Set name="scanInterval">1</Set>
      <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default<nowiki>=</nowiki>"."/>/etc/webdefault.xml</Set>
+
                <Set name="contextXmlDir"><Property name="jetty.home" default="." />/contexts</Set>
    </New>
+
<Set name="extractWars">true</Set>
  </Arg>
+
              </New>
</Call>
+
            </Arg>
 +
          </Call>
 +
    </Ref>
 +
</Configure>
 
</source>
 
</source>
  
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 WebAppProvider 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 '''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 '''contextXmlDir''' points to a directory like that which is used in the ContextProvider, using this option will tell the webapp provider to check any webapp or war files in the monitored directory for an associated context file and if it finds one will defer to the ContextProvider for deploying the webapp.  If none is found then this provider is used.
 +
 
 +
The '''monitoredDirName''' 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 [[Jetty/Feature/Classloading|classloading]] will be used or the servlet specification webapp [[Jetty/Feature/Classloading|classloading]] priority.
 
The '''parentLoaderPriority''' parameter is a boolean that selects of the standard java parent first delegation [[Jetty/Feature/Classloading|classloading]] will be used or the servlet specification webapp [[Jetty/Feature/Classloading|classloading]] priority.

Revision as of 15:06, 27 April 2011



Introduction

The WebAppProvider 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 Provider.

Feature

The basic operation of WebAppProvider 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 style file, in the jetty distribution this file is called 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>

The WebAppProvider 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 contextXmlDir points to a directory like that which is used in the ContextProvider, using this option will tell the webapp provider to check any webapp or war files in the monitored directory for an associated context file and if it finds one will defer to the ContextProvider for deploying the webapp. If none is found then this provider is used.

The monitoredDirName 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.