Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The deployment descriptors are in jetty xml format and are define and configure individual contexts. A minimal example is:

Code Block
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/test</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test</Set>
</Configure>

...

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.

Property value substitution

The ContextDeployer can automatically do property substitution on the context files that it deploys. You define a ConfigurationManager that manages the properties and pass this into the ContextDeployer. There is currently one implementation of the ConfigurationManager, and that is the org.mortbay.jetty.deployer.FileConfigurationManager that reads a properties file and makes available the property values to the ContextDeployer. Here's how you would configure the ContextDeployer:

Code Block

<Call name="addLifeCycle">
  <Arg>
    <New class="org.mortbay.jetty.deployer.ContextDeployer">
      <Set name="contexts"><Ref id="Contexts"/></Set>
      <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
      <Set name="scanInterval">1</Set>
      <Set name="configurationManager">
        <New class="org.mortbay.jetty.deployer.FileConfigurationManager">
          <Set name="file"><SystemProperty name="jetty.home" default="."/>/foo.properties</Set>
        </New>
      </Set>
    </New>
  </Arg>
</Call>

Here's an example of the contents of the foo.properties file:

Code Block

foo = /funkyapp

Here's how you would use this in a context xml file:

Code Block

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath"><Property name="foo"/></Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test</Set>
</Configure>

Contexts

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.

...

Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery