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

<Configure id="Server" class="org.eclipse.jetty.server.Server">
    <!-- =============================================================== -->
    <!-- Setup MBean Server early                                        -->
    <!-- =============================================================== -->
    <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>

    <!-- =========================================================== -->
    <!-- Server Thread Pool                                          -->
    <!-- =========================================================== -->
    <Set name="ThreadPool">
        <!-- Default queued blocking threadpool -->
        <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
            <Set name="minThreads">
                <SystemProperty name="xn.server.threads.min" default="10"/>
            </Set>
            <Set name="maxThreads">
                <SystemProperty name="xn.server.threads.max" default="200"/>
            </Set>
        </New>
    </Set>

    <!-- =========================================================== -->
    <!-- Set connectors                                              -->
    <!-- =========================================================== -->

    <!-- Use this connector if NIO is not available. -->
    <Call name="addConnector">
        <Arg>
            <New class="org.eclipse.jetty.server.bio.SocketConnector">
                <Set name="host">
                    <SystemProperty name="xn.server.ip"/>
                </Set>
                <Set name="port">
                    <SystemProperty name="xn.server.port" default="8080"/>
                </Set>
                <Set name="maxIdleTime">300000</Set>
                <Set name="Acceptors">2</Set>
                <Set name="statsOn">true</Set>
                <Set name="confidentialPort">
                    <SystemProperty name="xn.server.ssl.port" default="8443"/>
                </Set>
            </New>
        </Arg>
    </Call>

    <Set name="handler">
        <New class="org.eclipse.jetty.server.handler.StatisticsHandler">
            <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>
                            <Item>
                                <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
                            </Item>
                        </Array>
                    </Set>
                </New>
            </Set>
        </New>
    </Set>

    <Ref id="RequestLog">
        <Set name="requestLog">
            <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
                <Arg>
                    <SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log
                </Arg>
                <Set name="retainDays">30</Set>
                <Set name="append">true</Set>
                <Set name="extended">false</Set>
                <Set name="LogTimeZone">GMT</Set>
            </New>
        </Set>
    </Ref>

    <Call name="addLifeCycle">
        <Arg>
            <New class="org.eclipse.jetty.deploy.ContextDeployer">
                <Set name="contexts">
                    <Ref id="Contexts"/>
                </Set>
                <Set name="configurationDir">
                    <SystemProperty name="xn.jetty.contextDir" default="contexts"/>
                </Set>
                <Set name="scanInterval">1</Set>
            </New>
        </Arg>
    </Call>

    <!-- =========================================================== -->
    <!-- extra options                                               -->
    <!-- =========================================================== -->
    <Set name="stopAtShutdown">true</Set>
    <Set name="sendServerVersion">false</Set>
    <Set name="sendDateHeader">true</Set>
    <Set name="gracefulShutdown">
        <SystemProperty name="xn.jetty.gracefulShutdownTimeoutInMs" default="1000"/>
    </Set>
</Configure>
