<?xml version="1.0" encoding="UTF-8"?>

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">

<!-- =============================================================== -->
<!-- Documentation of this file format can be found at:              -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax        -->
<!--                                                                 -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
<!-- and can be mixed in. See start.ini file for the default         -->
<!-- configuration files.                                            -->
<!--                                                                 -->
<!-- For a description of the configuration mechanism, see the       -->
<!-- output of:                                                      -->
<!--   java -jar start.jar -?                                        -->
<!-- =============================================================== -->

<!-- =============================================================== -->
<!-- Configure a Jetty Server instance with an ID "Server"           -->
<!-- Other configuration files may also configure the "Server"       -->
<!-- ID, in which case they are adding configuration to the same     -->
<!-- instance.  If other configuration have a different ID, they     -->
<!-- will create and configure another instance of Jetty.            -->
<!-- Consult the javadoc of o.e.j.server.Server for all              -->
<!-- configuration that may be set here.                             -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">

  <!-- =========================================================== -->
  <!-- Configure the Server Thread Pool.                           -->
  <!-- The server holds a common thread pool which is used by      -->
  <!-- default as the executor used by all connectors and servlet  -->
  <!-- dispatches.                                                 -->
  <!--                                                             -->
  <!-- Configuring a fixed thread pool is vital to controlling the -->
  <!-- maximal memory footprint of the server and is a key tuning  -->
  <!-- parameter for tuning.  In an application that rarely blocks -->
  <!-- then maximal threads may be close to the number of 5*CPUs.  -->
  <!-- In an application that frequently blocks, then maximal      -->
  <!-- threads should be set as high as possible given the memory  -->
  <!-- available.                                                  -->
  <!--                                                             -->
  <!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool   -->
  <!-- for all configuration that may be set here.                 -->
  <!-- =========================================================== -->
  <!-- uncomment to change type of threadpool
  <Arg name="threadpool"><New id="threadpool" class="org.eclipse.jetty.util.thread.QueuedThreadPool"/></Arg>
  -->
  <Get name="ThreadPool">
    <Set name="minThreads" type="int"><Property name="threads.min" default="10"/></Set>
    <Set name="maxThreads" type="int"><Property name="threads.max" default="200"/></Set>
    <Set name="idleTimeout" type="int"><Property name="threads.timeout" default="60000"/></Set>
    <Set name="detailedDump">false</Set>
  </Get>

  <!-- =========================================================== -->
  <!-- Add shared Scheduler instance                               -->
  <!-- =========================================================== -->
  <!--
  <Call name="addBean">
    <Arg>
      <New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/>
    </Arg>
  </Call>
  -->

  <!-- =========================================================== -->
  <!-- Http Configuration.                                         -->
  <!-- This is a common configuration instance used by all         -->
  <!-- connectors that can carry HTTP semantics (HTTP, HTTPS, SPDY)-->
  <!-- It configures the non wire protocol aspects of the HTTP     -->
  <!-- semantic.                                                   -->
  <!--                                                             -->
  <!-- This configuration is only defined here and is used by      -->
  <!-- reference from the jetty-http.xml, jetty-https.xml and      -->
  <!-- jetty-spdy.xml configuration files which instantiate the    -->
  <!-- connectors.                                                 -->
  <!--                                                             -->
  <!-- Consult the javadoc of o.e.j.server.HttpConfiguration       -->
  <!-- for all configuration that may be set here.                 -->
  <!-- =========================================================== -->
  <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
    <Set name="secureScheme">https</Set>
    <Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
    <Set name="outputBufferSize"><Property name="jetty.output.buffer.size" default="32768" /></Set>
    <Set name="requestHeaderSize"><Property name="jetty.request.header.size" default="8192" /></Set>
    <Set name="responseHeaderSize"><Property name="jetty.response.header.size" default="8192" /></Set>
    <Set name="sendServerVersion"><Property name="jetty.send.server.version" default="true" /></Set>
    <Set name="sendDateHeader"><Property name="jetty.send.date.header" default="false" /></Set>
    <Set name="headerCacheSize">512</Set>
    <!-- Uncomment to enable handling of X-Forwarded- style headers
    <Call name="addCustomizer">
      <Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
    </Call>
    -->
  </New>


  <!-- =========================================================== -->
  <!-- Set the default handler structure for the Server            -->
  <!-- A handler collection is used to pass received requests to   -->
  <!-- both the ContextHandlerCollection, which selects the next   -->
  <!-- handler by context path and virtual host, and the           -->
  <!-- DefaultHandler, which handles any requests not handled by   -->
  <!-- the context handlers.                                       -->
  <!-- Other handlers may be added to the "Handlers" collection,   -->
  <!-- for example the jetty-requestlog.xml file adds the          -->
  <!-- RequestLogHandler after the default handler                 -->
  <!-- =========================================================== -->
  <Set name="handler">
    <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
      <Set name="handlers">
        <Array type="org.eclipse.jetty.server.Handler">
          <Item>
            <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
          </Item>
          <Item>
            <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
          </Item>
        </Array>
      </Set>
    </New>
  </Set>

  <!-- =========================================================== -->
  <!-- extra server options                                        -->
  <!-- =========================================================== -->
  <Set name="stopAtShutdown">true</Set>
  <Set name="stopTimeout">5000</Set>
  <Set name="dumpAfterStart"><Property name="jetty.dump.start" default="false"/></Set>
  <Set name="dumpBeforeStop"><Property name="jetty.dump.stop" default="false"/></Set>

  <!-- In order to avoid getting a "java.lang.IllegalStateException: Form too large" error when editing large page in
       XWiki we need to tell Jetty to allow for large content since by default it only allows for 20K. We do this by
       passing the "org.eclipse.jetty.server.Request.maxFormContentSize" attribute.
       Note that setting this value too high can leave your server vulnerable to denial of service attacks.
  -->
  <Call name="setAttribute">
    <Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
    <Arg><Property name="jetty.maxFormContentSize" default="1000000"/></Arg>
  </Call>

</Configure>
