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

<!--
  ~ /*
  ~  * JBoss, Home of Professional Open Source.
  ~  * Copyright 2013, Red Hat, Inc., and individual contributors
  ~  * as indicated by the @author tags. See the copyright.txt file in the
  ~  * distribution for a full listing of individual contributors.
  ~  *
  ~  * 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.
  ~  */
  -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="urn:jboss:domain:undertow:1.0"
           targetNamespace="urn:jboss:domain:undertow:1.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           version="1.0">
    <!-- The undertow subsystem root element -->
    <xs:element name="subsystem" type="undertow-subsystemType"/>
    <xs:complexType name="undertow-subsystemType">
        <xs:annotation>
            <xs:documentation>
                <![CDATA[
                The configuration of the undertow subsystem.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="buffer-caches" type="buffer-cachesType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="server" type="serverType" minOccurs="1" maxOccurs="unbounded"/>
            <xs:element name="servlet-container" type="servletContainerType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="error-pages" type="errorPagesType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="handlers" type="handlerType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="filters" type="servletContainerType" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="default-server" type="xs:string" default="default-server"/>
        <xs:attribute name="default-virtual-host" type="xs:string" default="default-host"/>
        <xs:attribute name="default-servlet-container" type="xs:string" default="default"/>
        <xs:attribute name="instance-id" type="xs:string" use="optional"/>
    </xs:complexType>
    <xs:complexType name="serverType">
        <xs:sequence>
            <xs:element name="http-listener" type="http-listener-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="https-listener" type="https-listener-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="ajp-listener" type="ajp-listener-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="host" type="hostType" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="default-host" use="optional" type="xs:string" default="default-host"/>
        <xs:attribute name="servlet-container" use="optional" type="xs:string" default="default"/>
    </xs:complexType>
    <xs:complexType name="http-listener-type">
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="socket-binding" use="required" type="xs:string"/>
        <xs:attribute name="worker" type="xs:string" default="default"/>
        <xs:attribute name="buffer-pool" type="xs:string" default="default"/>
        <xs:attribute name="enabled" type="xs:boolean" default="true"/>
    </xs:complexType>
    <xs:complexType name="https-listener-type">
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="socket-binding" use="required" type="xs:string"/>
        <xs:attribute name="worker" type="xs:string" default="default"/>
        <xs:attribute name="buffer-pool" type="xs:string" default="default"/>
        <xs:attribute name="enabled" type="xs:boolean" default="true"/>
        <xs:attribute name="security-realm" use="required" type="xs:string"/>
    </xs:complexType>
    <xs:complexType name="ajp-listener-type">
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="socket-binding" use="required" type="xs:string"/>
        <xs:attribute name="worker" type="xs:string" default="default"/>
        <xs:attribute name="buffer-pool" type="xs:string" default="default"/>
        <xs:attribute name="enabled" type="xs:boolean" default="true"/>
        <xs:attribute name="scheme" type="xs:string" default="http"/>
    </xs:complexType>
    <xs:complexType name="servletContainerType">
        <xs:sequence>
            <xs:element name="jsp-config" type="jsp-configurationType" maxOccurs="1" minOccurs="0"/>
            <xs:element name="session-cookie" type="session-cookieType" maxOccurs="1" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="name" use="required" type="xs:string"/>
    </xs:complexType>
    <xs:complexType name="hostType">
        <xs:sequence>
            <xs:element name="location" type="locationType" maxOccurs="1" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="alias" use="optional" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="jsp-configurationType">
        <xs:attribute name="development" default="false" type="xs:boolean"/>
        <xs:attribute name="disabled" default="false" type="xs:boolean"/>
        <xs:attribute name="keep-generated" default="true" type="xs:boolean"/>
        <xs:attribute name="trim-spaces" default="false" type="xs:boolean"/>
        <xs:attribute name="tag-pooling" default="true" type="xs:boolean"/>
        <xs:attribute name="mapped-file" default="true" type="xs:boolean"/>
        <xs:attribute name="check-interval" default="0" type="xs:int"/>
        <xs:attribute name="modification-test-interval" default="4" type="xs:int"/>
        <xs:attribute name="recompile-on-fail" default="false" type="xs:boolean"/>
        <xs:attribute name="smap" default="true" type="xs:boolean"/>
        <xs:attribute name="dump-smap" default="false" type="xs:boolean"/>
        <xs:attribute name="generate-strings-as-char-arrays" default="false" type="xs:boolean"/>
        <xs:attribute name="error-on-use-bean-invalid-class-attribute" default="false" type="xs:boolean"/>
        <xs:attribute name="scratch-dir" type="xs:string"/>
        <xs:attribute name="source-vm" default="1.6" type="xs:string"/>
        <xs:attribute name="target-vm" default="1.6" type="xs:string"/>
        <xs:attribute name="java-encoding" default="UTF8" type="xs:string"/>
        <xs:attribute name="x-powered-by" default="true" type="xs:boolean"/>
        <xs:attribute name="display-source-fragment" default="true" type="xs:boolean"/>
    </xs:complexType>

    <xs:complexType name="session-cookieType">
        <xs:attribute name="name" type="xs:string"/>
        <xs:attribute name="domain" type="xs:string"/>
        <xs:attribute name="comment" type="xs:string"/>
        <xs:attribute name="http-only" type="xs:boolean"/>
        <xs:attribute name="secure" type="xs:boolean"/>
        <xs:attribute name="max-age" type="xs:int"/>
    </xs:complexType>
    <xs:complexType name="handlerType">
        <xs:sequence>
            <xs:element name="file" type="file-handlerType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="errorPagesType">
        <xs:sequence>
            <xs:element name="error-page" type="errorPageType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="locationType">
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="handler" use="required" type="xs:string"/>
    </xs:complexType>
    <xs:complexType name="errorPageType">
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="code" use="required" type="xs:string"/>
        <xs:attribute name="path" use="required" type="xs:string"/>
    </xs:complexType>
    <xs:complexType name="file-handlerType">
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="path" use="required" type="xs:string"/>
        <xs:attribute name="cache-buffer-size" use="optional" type="xs:int" default="1024"/>
        <xs:attribute name="cache-buffers" use="optional" type="xs:int" default="1024"/>
        <xs:attribute name="directory-listing" use="optional" type="xs:boolean" default="true"/>
    </xs:complexType>

    <xs:complexType name="buffer-cachesType">
        <xs:annotation>
            <xs:documentation>
                <![CDATA[
                  The configuration of buffer caches that are used to cache response data.
                ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="buffer-cache" type="buffer-cacheType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="buffer-cacheType">
        <xs:annotation>
            <xs:documentation>
                <![CDATA[
                  A buffer cache. I cache consists of 1 or more regions, that are split up into smaller buffers.
                  The total cache size is the buffer size * the buffers per region * the number of regions.
                ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="buffer-size" use="required" type="xs:string"/>
        <xs:attribute name="buffers-per-region" use="required" type="xs:string"/>
        <xs:attribute name="max-regions" use="required" type="xs:string"/>
    </xs:complexType>
</xs:schema>
