Jump to: navigation, search

Difference between revisions of "Jetty/Feature/Hot Deployment"

< Jetty‎ | Feature
m
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{Jetty Feature
 
{{Jetty Feature
 
| introduction =
 
| introduction =
Jetty provides capability to deploy an arbitrary context or web application by monitoring a configuration directory for changes to the deployment descriptors. If a descriptor is added to the directory, a new context will be deployed. If a descriptor is touched/updated then it's context will be stopped, reconfigured and redeployed. If a descriptor is removed, then it's context will be stopped and removed from the server. This capability is implemented via [[Jetty/Feature/ContextDeployer|Context Deployer]] mechanism.  
+
 
 +
{{Jetty Redirect|http://www.eclipse.org/jetty/documentation/current/hot-deployment.html}}
 +
 
 +
Jetty provides capability to deploy an arbitrary context or web application by monitoring a directory for changes. If you add a web application or a context descriptor to the directory, Jetty's Deployment Manager (DM) deploys a new context. If you touch or update a context descriptor, the DM stops, reconfigures, and redeploys its context. If you remove a context, the DM stops it and removes it from the server.
  
 
| body =
 
| body =
The [[Jetty/Feature/ContextDeployer|Context Deployer]] may be used to (hot)deploy an arbitrary Context or Web Application with Jetty specific configuration. The deployment descriptors are in [[Jetty/Reference/jetty.xml syntax|jetty xml]] format and define and configure individual contexts. If the scan interval is non-zero, the configuration directory is scanned at that interval (in seconds) for changes to the deployment descriptors.
 
If the scan interval is zero, then the directory is only scanned at startup.
 
  
To statically deploy only standard web applications at startup, use the [[JETTY/Feature/WebAppDeployer|WebApp Deployer]].
+
The deployment manager is a state-oriented mechanism suitable for developers and embedded users to customize to a variety of use cases.  An example follows of the <tt>jetty.xml</tt> that creates the basic deployment manager, which Jetty then uses to plug in the ContextProvider and the WebAppProvider that back the Hot Deployment mechanism.  This example also provides information about adding another node to the deployment state, in this case a debug binding.  In the Jetty distribution this XML is in the <tt>jetty-deploy.xml</tt> file, which combined with the <tt>jetty-contexts.xml</tt> and <tt>jetty-webapps.xml</tt> files comprise the stock jetty hot deployment mechanism.
 +
 
 +
<source lang="xml">
 +
<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 id="Contexts" />
 +
          </Set>
 +
          <Call name="setContextAttribute">
 +
            <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
 +
            <Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
 +
          </Call>
 +
         
 +
         
 +
          <!-- Add a customize step to the deployment lifecycle -->
 +
          <!-- uncomment and replace DebugBinding with your extended AppLifeCycle.Binding class
 +
          <Call name="insertLifeCycleNode">
 +
            <Arg>deployed</Arg>
 +
            <Arg>starting</Arg>
 +
            <Arg>customise</Arg>
 +
          </Call>
 +
          <Call name="addLifeCycleBinding">
 +
            <Arg>
 +
              <New class="org.eclipse.jetty.deploy.bindings.DebugBinding">
 +
                <Arg>customise</Arg>
 +
              </New>
 +
            </Arg>
 +
          </Call>
 +
          -->
 +
         
 +
        </New>
 +
      </Arg>
 +
    </Call>
 +
</Configure>
 +
</source>
 +
 
 +
| more =
 +
See the [[Jetty/Feature/ContextDeployer|Context Provider]] and [[Jetty/Feature/WebAppDeployer|WebApp Provider]] documentation for more information. Previously, Jetty implemented this feature via a ContextDeployer and WebappDeployer, which have both been deprecated.  
  
| category = [[Category:Jetty Feature]]
+
See also the [[Jetty/Feature/Deployment_Manager|Deployment Manager]] feature reference for detailed conceptual information.
 
}}
 
}}

Latest revision as of 14:01, 23 April 2013



Introduction


Jetty provides capability to deploy an arbitrary context or web application by monitoring a directory for changes. If you add a web application or a context descriptor to the directory, Jetty's Deployment Manager (DM) deploys a new context. If you touch or update a context descriptor, the DM stops, reconfigures, and redeploys its context. If you remove a context, the DM stops it and removes it from the server.

Feature

The deployment manager is a state-oriented mechanism suitable for developers and embedded users to customize to a variety of use cases. An example follows of the jetty.xml that creates the basic deployment manager, which Jetty then uses to plug in the ContextProvider and the WebAppProvider that back the Hot Deployment mechanism. This example also provides information about adding another node to the deployment state, in this case a debug binding. In the Jetty distribution this XML is in the jetty-deploy.xml file, which combined with the jetty-contexts.xml and jetty-webapps.xml files comprise the stock jetty hot deployment mechanism.

<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 id="Contexts" />
          </Set>
          <Call name="setContextAttribute">
            <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
            <Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
          </Call>
 
 
          <!-- Add a customize step to the deployment lifecycle -->
          <!-- uncomment and replace DebugBinding with your extended AppLifeCycle.Binding class 
          <Call name="insertLifeCycleNode">
            <Arg>deployed</Arg>
            <Arg>starting</Arg>
            <Arg>customise</Arg>
          </Call>
          <Call name="addLifeCycleBinding">
            <Arg>
              <New class="org.eclipse.jetty.deploy.bindings.DebugBinding">
                <Arg>customise</Arg>
              </New>
            </Arg>
          </Call>
          -->
 
        </New>
      </Arg>
    </Call>
</Configure>

Additional Resources

See the Context Provider and WebApp Provider documentation for more information. Previously, Jetty implemented this feature via a ContextDeployer and WebappDeployer, which have both been deprecated.

See also the Deployment Manager feature reference for detailed conceptual information.