alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Jetty example source code file (other-jetty.xml)

This example Jetty source code file (other-jetty.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Jetty tags/keywords

arg, arg, array, call, call, configure, item, new, new, ref, server, set, set, systemproperty

The Jetty other-jetty.xml source code

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<!-- =============================================================== -->
<!-- Configure the Jetty Server                                      -->
<!--                                                                 -->
<!-- Documentation of this file format can be found at:              -->
<!-- http://docs.codehaus.org/display/JETTY/jetty.xml                -->
<!--                                                                 -->
<!-- =============================================================== -->


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

    <!-- =========================================================== -->
    <!-- Server Thread Pool                                          -->
    <!-- =========================================================== -->
    <Set name="ThreadPool">
      <!-- Default bounded blocking threadpool 
      -->
      <New class="org.mortbay.thread.BoundedThreadPool">
        <Set name="minThreads">10
        <Set name="maxThreads">250
        <Set name="lowThreads">25
      </New>

      <!-- Optional Java 5 bounded threadpool with job queue 
      <New class="org.mortbay.thread.concurrent.ThreadPool">
        <Set name="corePoolSize">250
        <Set name="maximumPoolSize">250
      </New>
      -->
    </Set>



    <!-- =========================================================== -->
    <!-- Set connectors                                              -->
    <!-- =========================================================== -->
    <!-- One of each type!                                           -->
    <!-- =========================================================== -->

    <!-- Use this connector for many frequently idle connections
         and for threadless continuations.
    -->    
    <Call name="addConnector">
      <Arg>
          <New class="org.mortbay.jetty.nio.SelectChannelConnector">
            <Set name="port">
            <Set name="maxIdleTime">30000
            <Set name="Acceptors">2
            <Set name="statsOn">false
            <Set name="confidentialPort">8443
	    <Set name="lowResourcesConnections">5000
	    <Set name="lowResourcesMaxIdleTime">5000
          </New>
      </Arg>
    </Call>

    <!-- Use this connector if NIO is not available.
    <Call name="addConnector">
      <Arg>
          <New class="org.mortbay.jetty.bio.SocketConnector">
            <Set name="port">8081
            <Set name="maxIdleTime">50000
            <Set name="lowResourceMaxIdleTime">1500
          </New>
      </Arg>
    </Call>
    -->

    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <!-- To add a HTTPS SSL listener                                     -->
    <!-- see jetty-ssl.xml to add an ssl connector. use                  -->
    <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml             -->
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    
    <!-- =========================================================== -->
    <!-- Set up a session ID manager for this node "alfred"          -->
    <!-- =========================================================== -->

      <New id="tcidmgr" class="org.mortbay.terracotta.servlet.TerracottaSessionIdManager">
        <Arg>
        <Set name="workerName">alfred
      </New>

    <Call name="setAttribute">
      <Arg>tcIdMgr
      <Arg>
    </Call>


    <!-- =========================================================== -->
    <!-- Set handler Collection Structure                            --> 
    <!-- =========================================================== -->
    <Set name="handler">
      <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
        <Set name="handlers">
         <Array type="org.mortbay.jetty.Handler">
           <Item>
             <New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
           </Item>
           <Item>
             <New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
           </Item>
           <Item>
             <New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
           </Item>
         </Array>
        </Set>
      </New>
    </Set>
    
    <!-- =========================================================== -->
    <!-- Configure the context deployer                              -->
    <!-- A context deployer will deploy contexts described in        -->
    <!-- configuration files discovered in a directory.              -->
    <!-- The configuration directory can be scanned for hot          -->
    <!-- deployments at the configured scanInterval.                 -->
    <!--                                                             -->
    <!-- This deployer is configured to deploy contexts configured   -->
    <!-- in the $JETTY_HOME/contexts directory                       -->
    <!--                                                             -->
    <!-- =========================================================== -->
    <Call name="addLifeCycle">
      <Arg>
        <New class="org.mortbay.jetty.deployer.ContextDeployer">
          <Set name="contexts">
          <Set name="configurationDir">/contexts
          <Set name="scanInterval">1
        </New>
      </Arg>
    </Call>

    <!-- =========================================================== -->
    <!-- Configure the webapp deployer.                              -->
    <!-- A webapp  deployer will deploy standard webapps discovered  -->
    <!-- in a directory at startup, without the need for additional  -->
    <!-- configuration files.    It does not support hot deploy or   -->
    <!-- non standard contexts (see ContextDeployer above).          -->
    <!--                                                             -->
    <!-- This deployer is configured to deploy webapps from the      -->
    <!-- $JETTY_HOME/webapps directory                               -->
    <!--                                                             -->
    <!-- Normally only one type of deployer need be used.            -->
    <!--                                                             -->
    <!-- =========================================================== -->
    <Call name="addLifeCycle">
      <Arg>
        <New class="org.mortbay.jetty.deployer.WebAppDeployer">
          <Set name="contexts">
          <Set name="webAppDir">/webapps
	  <Set name="parentLoaderPriority">false
	  <Set name="extract">true
	  <Set name="allowDuplicates">false
          <Set name="defaultsDescriptor">/etc/webdefault.xml
        </New>
      </Arg>
    </Call>

    <!-- =========================================================== -->
    <!-- Configure Authentication Realms                             -->
    <!-- Realms may be configured for the entire server here, or     -->
    <!-- they can be configured for a specific web app in a context  -->
    <!-- configuration (see $(jetty.home)/contexts/test.xml for an   -->
    <!-- example).                                                   -->
    <!-- =========================================================== -->
    <Set name="UserRealms">
      <Array type="org.mortbay.jetty.security.UserRealm">
        <!--
        <Item>
          <New class="org.mortbay.jetty.security.HashUserRealm">
            <Set name="name">Test Realm
            <Set name="config">/etc/realm.properties
          </New>
        </Item>
	-->
      </Array>
    </Set>

    <!-- =========================================================== -->
    <!-- Configure Request Log                                       -->
    <!-- Request logs  may be configured for the entire server here, -->
    <!-- or they can be configured for a specific web app in a       -->
    <!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
    <!-- for an example).                                            -->
    <!-- =========================================================== -->
    <Ref id="RequestLog">
      <Set name="requestLog">
        <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
          <Arg>/yyyy_mm_dd.request.log
          <Set name="retainDays">90
          <Set name="append">true
          <Set name="extended">false
          <Set name="LogTimeZone">GMT
        </New>
      </Set>
    </Ref>

    <!-- =========================================================== -->
    <!-- extra options                                               -->
    <!-- =========================================================== -->
    <Set name="stopAtShutdown">true
    <Set name="sendServerVersion">true
    <Set name="sendDateHeader">true

</Configure>

Other Jetty examples (source code examples)

Here is a short list of links related to this Jetty other-jetty.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.