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

<!--
  ~ JBoss, Home of Professional Open Source
  ~
  ~ Copyright 2017 Red Hat, Inc. and/or its affiliates.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:xnio:3.5"
            xmlns="urn:xnio:3.5"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0">

    <xs:element name="worker" type="worker-type"/>

    <xs:complexType name="worker-type">
        <xs:all minOccurs="0" maxOccurs="1">
            <xs:element name="daemon-threads" type="boolean-value-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="worker-name" type="string-value-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="pool-size" type="pool-size-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="task-keepalive" type="positive-value-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="io-threads" type="positive-value-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="stack-size" type="positive-value-type" minOccurs="0" maxOccurs="1"/>
            <xs:element name="outbound-bind-addresses" type="bind-addresses-type" minOccurs="0" maxOccurs="1"/>
        </xs:all>
    </xs:complexType>

    <xs:simpleType name="non-empty-string-type">
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="boolean-value-type">
        <xs:attribute name="value" type="xs:boolean" use="required"/>
    </xs:complexType>

    <xs:complexType name="string-value-type">
        <xs:attribute name="value" type="non-empty-string-type" use="required"/>
    </xs:complexType>

    <xs:complexType name="pool-size-type">
        <xs:attribute name="max-threads" type="xs:positiveInteger" use="required"/>
    </xs:complexType>

    <xs:complexType name="positive-value-type">
        <xs:attribute name="value" type="xs:positiveInteger" use="required"/>
    </xs:complexType>

    <xs:complexType name="bind-addresses-type">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="bind-address" type="bind-address-type"/>
        </xs:choice>
    </xs:complexType>

    <xs:complexType name="bind-address-type">
        <xs:attribute name="match" type="xs:string"/>
        <xs:attribute name="bind-address" type="xs:string"/>
        <xs:attribute name="bind-port" type="xs:nonNegativeInteger"/>
    </xs:complexType>
</xs:schema>
