Versions Compared

Key

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

...

Section
Column
Code Block
xml
bgColorFFFFFF
xml
titleBGColor#54FF9F
titlejettyA.xml
<Configure id="ServerA" class="org.mortbay.jetty.Server">

   <Set name="ThreadPool">

    ...
 <!-- set up the port for ServerA -->
    </Set>
    <Set name="connectors">
      <Array type="org.mortbay.jetty.Connector">
        <Item>
          <New class="org.mortbay.jetty.nio.SelectChannelConnector">
            <Set name="port">8080</Set>
            <Set name="maxIdleTime">30000</Set>
            <Set name="Acceptors">10</Set>
          </New>
        </Item>
      </Array>
    </Set>

    ...

    <New id="webAppA"  <!-- set up a context deployer for Server A -->
    <Call name="addLifeCycle">
      <Arg>
        <New class="org.mortbay.jetty.webappdeployer.WebAppContextContextDeployer">
          <Set  <Arg><Ref name="contexts"><Ref id="Contexts"/></Arg>Set>
      <Arg><SystemProperty    <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/webappscontextsA</A</Arg>Set>
      <Arg>/webappA</Arg>    <Set name="scanInterval">5</Set>
 ...       </New>
     ... </Arg>
    </Call>

</Configure>
Column
Code Block
xml
bgColorFFFFFF
xml
titleBGColor#AB82FF
titlejettyB.xml

<Configure id="ServerB" class="org.mortbay.jetty.Server">

   <Set name="ThreadPool">

    ...
 <!-- set up the port for ServerB -->
    </Set>
    <Set name="connectors">
      <Array type="org.mortbay.jetty.Connector">
        <Item>
          <New class="org.mortbay.jetty.security.SslSocketConnector">
            <Set name="Port">8443</Set>
            <Set name="maxIdleTime">30000</Set>
            <Set name="Keystore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
            <Set name="Password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
            <Set name="KeyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
          </New>
        </Item>
      </Array>
    </Set>

     ...


    <New id="webAppB"  <!-- set up a context deployer for ServerB -->
      <Arg>
        <New class="org.mortbay.jetty.webappdeployer.WebAppContextContextDeployer">
      <Arg><Ref     <Set name="contexts"><Ref id="Contexts"/></Arg>Set>
      <Arg><SystemProperty    <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/webapps/B</Arg>contextsB</Set>
          <Set name="scanInterval">5</Set>
      <Arg>/webappB<  </New>
      </Arg>
    </Call>

</Configure>

Now we need to set up 2 context files, one to describe the webapp we wish to deploy on Server A and the other for the webapp to deploy on Server B. We then put these files into $JETTY_HOME/contextsA or $JETTY_HOME/contextsB respectively.

Section
Column

{code:xml|title=contextA.xml|titleBGColor=#54FF9F|bgColor=FFFFFF
<Configure i class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="war"><SystemProperty name="jetty.home"/>/webapps/A</Set>
<Set name="contextPath">/webappA</Set>
...
</Configure>

Code Block
Column
Code Block
xml
bgColorFFFFFF
xml
titleBGColor#AB82FF
titlecontextB.xml
    </New><Configure i class="org.mortbay.jetty.webapp.WebAppContext">
      <Set name="war"><SystemProperty name="jetty.home"/>/webapps/B</Set>
      <Set name="contextPath">/webappB</Set>
       ...
    </Configure>

You run both Server instances in the same JVM by providing them both on the runline:

...

Code Block
xml
xml
titlejetty.xml

<Configure class="org.mortbay.jetty.Server">

   <Set name="ThreadPool">

    ... <!-- set up both connectors -->
     <Set name="connectors">
      <Array type="org.mortbay.jetty.Connector">
        <Item>
          <New  class="org.mortbay.jetty.nio.SelectChannelConnector">
            <Set name="port">8080</Set>
            <Set name="maxIdleTime">30000</Set>
            <Set name="Acceptors">1</Set>
            <Set name="name">connA</Set>
          </New>
        </Item>
        <Item>
          <New id="connB" class="org.mortbay.jetty.nio.SelectChannelConnector">
            <Set name="port">9090</Set>
            <Set name="maxIdleTime">30000</Set>
            <Set name="Acceptors">1</Set>            
            <Set name="name">connB</Set>
          </New>
        </Item>
      </Array>
    </Set>

</Configure>
Code Block
xml
xml
title"contextA.xml"
  <New id="webAppA" <Configure  class="org.mortbay.jetty.webapp.WebAppContext">      
      <Arg><Ref<Set idname="Contexts"/></Arg>
      <Arg><SystemProperty war"><SystemProperty name="jetty.home"/>/webapps/A</Arg>Set>
      <Arg><Set name="contextPath">/webappA</Arg>Set>
      <Set name="connectorNames">
        <Array type="String">
          <Item>0.0.0.0:8080<<Item>connA</Item>
        </Array>
       </Set>
      ...
    </New>
 
     ...Configure>
Code Block
xml
xml
title"contextB.xml"
    <Configure <New id="webAppB"  class="org.mortbay.jetty.webapp.WebAppContext">
      <Arg><Ref<Set idname="Contexts"/></Arg>
      <Arg><SystemProperty war"><SystemProperty name="jetty.home"/>/webapps/B</Arg>Set>
      <Arg><Set name="contextPath"/webappB</Arg>Set>
      <Set name="connectorNames">
        <Array type="String">
          <Item>0.0.0.0:9090<<Item>connB</Item>
        </Array>
      </Set>
       ...
    </New>

    ...

</Configure>
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