The ContextDeployer may be used to (hot)deploy an arbitrary Context or Web Application with Jetty specific configuration. To statically deploy only standard web applications at startup, use the WebAppDeployer.
Typically a ContextDeployer is defined in a jetty.xml file:
The ContextDeployer will scan the configurationDir directory at intervals of scanInterval seconds for xml descriptors that define contexts. Any contexts found are deployed to the passed contexts reference to a HandlerContainer (this is normally an instance of ContextHandlerCollection).
The deployment descriptors are in jetty xml format and are define and configure individual contexts. A minimal example is
This example creates an instance of org.mortbay.jetty.webapp.WebAppContext and sets the contextPath to be "/test" and the resourceBase to be "$jetty.home/webapps/test". Because the context used is a standard web application context, when started it will inspect the resourceBase for a WEB-INF/web.xml for further configuration.
The ContextDeployer 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.
Because the class of the context is defined in the Configure clause, any type of ContextHandler may be deployed with this mechanism, included base ContextHandlers, servlet Contexts, WebAppContexts or any class derived from them.
If the scan interval is non-zero, the configuration directory is scanned at that interval (in seconds) for changes to the deployment descriptors. If a descriptor is added to the directory, the 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.
If the scan interval is zero, then the directory is only scanned at startup.
Other things to configure
This mechanism allows the most of the API available on ContextHandler or its derived classes to be called to configure the web application. Useful things to configure include: