<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<!--

    Copyright (c) 2010, Sebastian Sdorra
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
    3. Neither the name of SCM-Manager; nor the names of its
       contributors may be used to endorse or promote products derived from this
       software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    http://bitbucket.org/sdorra/scm-manager


-->

<!--
    Document   : server-config.xml
    Created on : January 20, 2011, 6:05 PM
    Author     : sdorra
    Description:
        Purpose of the document follows.
-->

<Configure id="ScmServer" class="org.eclipse.jetty.server.Server">

  <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
    <!-- increase header size for mercurial -->
    <Set name="requestHeaderSize">16384</Set>
    <Set name="responseHeaderSize">16384</Set>

    <!-- forwarding
    <Call name="addCustomizer">
      <Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
    </Call>
    -->
  </New>
  
  <!--
  Connectors
  -->
  <Call name="addConnector">
    <Arg>
      <New class="org.eclipse.jetty.server.ServerConnector">
        <Arg name="server">
          <Ref refid="ScmServer" />
        </Arg>
        <Arg name="factories">
          <Array type="org.eclipse.jetty.server.ConnectionFactory">
            <Item>
              <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                <Arg name="config">
                  <Ref refid="httpConfig" />
                </Arg>
              </New>
            </Item>
          </Array>
        </Arg>
        <Set name="port">
          <SystemProperty name="jetty.port" default="8080" />
        </Set>
      </New>
    </Arg>
  </Call>

  <New id="scm-webapp" class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/scm</Set>
    <Set name="war">
      <SystemProperty name="basedir" default="."/>/var/webapp/scm-webapp.war</Set>
    <!-- disable directory listings -->
    <Call name="setInitParameter">
      <Arg>org.eclipse.jetty.servlet.Default.dirAllowed</Arg>
      <Arg>false</Arg>
    </Call>
    <Set name="tempDirectory">
      <SystemProperty name="basedir" default="."/>/work/scm
    </Set>
  </New>

  <New id="docroot" class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/</Set>
    <Set name="baseResource">
      <New class="org.eclipse.jetty.util.resource.ResourceCollection">
        <Arg>
          <Array type="java.lang.String">
            <Item>
              <SystemProperty name="basedir" default="."/>/var/webapp/docroot</Item>
          </Array>
        </Arg>
      </New>
    </Set>
    <Set name="tempDirectory">
      <SystemProperty name="basedir" default="."/>/work/docroot
    </Set>
  </New>
  
  <Set name="handler">
    <New class="org.eclipse.jetty.server.handler.HandlerCollection">
      <Set name="handlers">
        <Array type="org.eclipse.jetty.server.Handler">
          <Item>
            <Ref id="scm-webapp" />
          </Item>
          <Item>
            <Ref id="docroot" />
          </Item>
        </Array>
      </Set>
    </New>
  </Set>
  
  <!-- TODO fix for jetty 9.2.x -->
  
  <!-- request logging -->
  <!--
  <Ref id="RequestLog">
    <Set name="requestLog">
      <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
        <Arg><SystemProperty name="basedir" default="."/>/var/log/yyyy_mm_dd.request.log</Arg>
        <Set name="retainDays">90</Set>
        <Set name="append">true</Set>
        <Set name="extended">false</Set>
        <Set name="LogTimeZone">GMT</Set>
       </New>
    </Set>
  </Ref>
  -->

  <!-- mod_proxy_ajp or mod_jk -->
  <!--
  <Call name="addConnector">
    <Arg>
       <New class="org.eclipse.jetty.ajp.Ajp13SocketConnector">
         <Set name="port">8009</Set>
       </New>
    </Arg>
  </Call>
  -->

  <!-- SSL-Connector -->
  <!--
     Documentation for the SSL-Connector: 
     http://wiki.eclipse.org/Jetty/Reference/SSL_Connectors
  -->
  <!--
  Besure SSLv3 protocol is excluded to avoid POODLE vulnerability.
  See https://groups.google.com/d/msg/scmmanager/sX_Ydy-wAPA/-Dvs5i7RHtQJ
  -->
  <!--
  <Call name="addConnector">
    <Arg>
      <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
        <Arg>
          <New class="org.eclipse.jetty.http.ssl.SslContextFactory">
            <Set name="excludeProtocols">
              <Array type="java.lang.String">
                <Item>SSLv2Hello</Item>
                <Item>SSLv3</Item>
              </Array>
            </Set>
          </New>
        </Arg>
        <Set name="Port">8181</Set>
        <Set name="maxIdleTime">30000</Set>
        <Set name="requestHeaderSize">16384</Set>
        <Set name="keystore"><SystemProperty name="basedir" default="." />/conf/keystore.jks</Set>
        <Set name="password">OBF:xxx</Set>
        <Set name="keyPassword">OBF:xxx</Set>
        <Set name="truststore"><SystemProperty name="basedir" default="." />/conf/keystore.jks</Set>
        <Set name="trustPassword">OBF:xxx</Set>
      </New>
    </Arg>
  </Call>
  -->

  <!-- JMX support -->
  <!--
  <Call id="MBeanServer" class="java.lang.management.ManagementFactory"
    name="getPlatformMBeanServer" />

  <New id="MBeanContainer" class="org.eclipse.jetty.jmx.MBeanContainer">
    <Arg>
      <Ref id="MBeanServer" />
    </Arg>
  </New>

  <Get id="Container" name="container">
    <Call name="addEventListener">
      <Arg>
        <Ref id="MBeanContainer" />
      </Arg>
    </Call>
  </Get>
  -->

</Configure>
