<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2019, 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 targetNamespace="urn:jboss:domain:jgroups:7.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="urn:jboss:domain:jgroups:7.0"
           xmlns:credential-reference="urn:wildfly:credential-reference:1.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           version="7.0">

    <xs:import namespace="urn:wildfly:credential-reference:1.0" schemaLocation="wildfly-credential-reference_1_0.xsd"/>

    <xs:element name="subsystem" type="tns:subsystem">
        <xs:annotation>
            <xs:documentation>Enumerates the protocol stacks available to the channel factory.</xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:complexType name="subsystem">
        <xs:all>
            <xs:element name="channels" type="tns:channels" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Enumerates the defined channels.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="stacks" type="tns:stacks">
                <xs:annotation>
                    <xs:documentation>Enumerates the defined protocol stacks.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:all>
    </xs:complexType>

    <xs:complexType name="channels">
        <xs:sequence>
            <xs:element name="channel" type="tns:channel" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>Defines a channel.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="default" type="xs:string">
            <xs:annotation>
                <xs:documentation>Identifies the default cluster.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="channel">
        <xs:sequence>
            <xs:element name="fork" type="tns:fork" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>Defines a fork of this channel.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    Defines the name of this channel.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="stack" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    Defines the stack used by this channel.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="cluster" type="xs:string">
            <xs:annotation>
                <xs:documentation>
                    Defines the cluster name of this channel.  If undefined, the channel name will be used.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="module" type="xs:string" default="org.wildfly.clustering.server">
            <xs:annotation>
                <xs:documentation>Indicates the module from which to load clustering services.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="statistics-enabled" type="xs:boolean" default="false">
            <xs:annotation>
                <xs:documentation>Indicates whether or not this channel will collect statistics.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="fork">
        <xs:sequence>
            <xs:element name="protocol" type="tns:protocol" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>Defines a protocol to add to the protocol stack of this fork channel.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    Defines the cluster name of this channel.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="stacks">
        <xs:sequence>
            <xs:element name="stack" type="tns:stack" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>Defines a protocol stack.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="default" type="xs:string">
            <xs:annotation>
                <xs:documentation>Deprecated. Identifies the default protocol stack.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="stack">
        <xs:sequence>
            <xs:element name="transport" type="tns:transport">
                <xs:annotation>
                    <xs:documentation>Defines the transport protocol for a stack.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="protocol" type="tns:protocol">
                    <xs:annotation>
                        <xs:documentation>Defines a non-transport protocol for a stack.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="socket-protocol" type="tns:socket-protocol">
                    <xs:annotation>
                        <xs:documentation>Defines a non-transport protocol for a stack.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="socket-discovery-protocol" type="tns:socket-discovery-protocol">
                    <xs:annotation>
                        <xs:documentation>Defines a non-transport protocol for a stack.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="jdbc-protocol" type="tns:jdbc-protocol">
                    <xs:annotation>
                        <xs:documentation>Defines a non-transport protocol for a stack.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="encrypt-protocol" type="tns:encrypt-protocol">
                    <xs:annotation>
                        <xs:documentation>Defines a non-transport protocol for a stack.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="auth-protocol" type="tns:auth-protocol">
                    <xs:annotation>
                        <xs:documentation>Defines a non-transport protocol for a stack.</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:choice>
            <xs:element name="relay" type="tns:relay" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Defines a relay protocol for a stack.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>Uniquely identifies this stack.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="statistics-enabled" type="xs:boolean" default="false">
            <xs:annotation>
                <xs:documentation>Indicates whether or not all protocols in the stack will collect statistics by default.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="generic-protocol">
        <xs:sequence>
            <xs:element name="property" type="tns:property" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>Defines a property override for a protocol.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="type" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>Identifies the protocol type, e.g. TCP, UDP, PING, etc.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="module" type="xs:string" default="org.jgroups">
            <xs:annotation>
                <xs:documentation>Indicates the module from which to load this protocol.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="statistics-enabled" type="xs:boolean">
            <xs:annotation>
                <xs:documentation>Indicates whether or not this protocol will collect statistics overriding stack configuration.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="protocol">
        <xs:complexContent>
            <xs:extension base="tns:generic-protocol">
                <xs:attribute name="socket-binding" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Deprecated.  Socket-based protocols should use &lt;socket-protocol/&gt; instead.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="socket-protocol">
        <xs:complexContent>
            <xs:extension base="tns:generic-protocol">
                <xs:attribute name="socket-binding" type="xs:string" use="required">
                    <xs:annotation>
                        <xs:documentation>Provides a socket binding for a protocol.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="client-socket-binding" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>The socket-binding used to configure the bind address/port of the socket used to send messages to other members.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="socket-discovery-protocol">
        <xs:complexContent>
            <xs:extension base="tns:generic-protocol">
                <xs:attribute name="socket-bindings" type="tns:list" use="required">
                    <xs:annotation>
                        <xs:documentation>Provides a list of socket bindings for a protocol.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="jdbc-protocol">
        <xs:complexContent>
            <xs:extension base="tns:generic-protocol">
                <xs:attribute name="data-source" type="xs:string" use="required">
                    <xs:annotation>
                        <xs:documentation>Data source reference for JDBC protocols to be used instead of connection and JNDI lookup properties.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="encrypt-protocol">
        <xs:complexContent>
            <xs:extension base="tns:generic-protocol">
                <xs:sequence>
                    <xs:element name="key-credential-reference" type="credential-reference:credentialReferenceType">
                        <xs:annotation>
                            <xs:documentation>References the password credential with which the key is protected.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="key-store" type="xs:string" use="required">
                    <xs:annotation>
                        <xs:documentation>References key store containing the key used to encrypt messages.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="key-alias" type="xs:string" use="required">
                    <xs:annotation>
                        <xs:documentation>The alias of the key used to encrypt.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="auth-protocol">
        <xs:complexContent>
            <xs:extension base="tns:generic-protocol">
                <xs:choice>
                    <xs:element name="plain-token" type="tns:plain-token">
                        <xs:annotation>
                            <xs:documentation>An auth token using a plain text shared secret.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="digest-token" type="tns:digest-token">
                        <xs:annotation>
                            <xs:documentation>An auth token using a digest of a shared secret.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="cipher-token" type="tns:cipher-token">
                        <xs:annotation>
                            <xs:documentation>An auth token using an encrypted shared secret.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="plain-token">
        <xs:sequence>
            <xs:element name="shared-secret-reference" type="credential-reference:credentialReferenceType">
                <xs:annotation>
                    <xs:documentation>References a shared secret used to authenticate new members.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="digest-token">
        <xs:complexContent>
            <xs:extension base="tns:plain-token">
                <xs:attribute name="algorithm" type="xs:string" default="SHA-265">
                    <xs:annotation>
                        <xs:documentation>The digest algorithm with which to obfuscate the shared secret.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="cipher-token">
        <xs:complexContent>
            <xs:extension base="tns:plain-token">
                <xs:sequence>
                    <xs:element name="key-credential-reference" type="credential-reference:credentialReferenceType">
                        <xs:annotation>
                            <xs:documentation>References the credential required to obtain the specified key from the specified store.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="key-store" type="xs:string" use="required">
                    <xs:annotation>
                        <xs:documentation>References key store containing the private key and certificate used to authenticate new members.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="key-alias" type="xs:string" use="required">
                    <xs:annotation>
                        <xs:documentation>The alias of the private key and certificate used to authenticate new members.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="algorithm" type="xs:string" default="RSA">
                    <xs:annotation>
                        <xs:documentation>The encryption algorithm/transformation used to protect the shared secret during transmission.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="transport">
        <xs:complexContent>
            <xs:extension base="tns:generic-protocol">
                <xs:sequence>
                    <xs:element name="default-thread-pool" type="tns:thread-pool" minOccurs="0" maxOccurs="1">
                        <xs:annotation>
                            <xs:documentation>Defines the thread pool used for default messages received by this transport.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="shared" type="xs:boolean" default="true">
                    <xs:annotation>
                        <xs:documentation>Indicates whether or not the channels created for this stack should use a single, shared transport.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="socket-binding" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>The socket-binding used to configure the bind address/port of the socket used to receive messages from other members.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="client-socket-binding" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>The socket-binding used to configure the bind address/port of the socket used to send messages to other members.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="diagnostics-socket-binding" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>If specified, enables diagnostics and specified the multicast address/port on which to communicate.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="default-executor" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Defines the thread pool used for default messages received by this transport.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="oob-executor" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Defines the thread pool used for OOB messages received by this transport.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="timer-executor" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Defines the timer thread pool used by this transport.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="thread-factory" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Defines the thread factory used by this transport.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="site" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Identifies the site where this node runs.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="rack" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Identifies the rack where this node runs.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="machine" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Identifies the machine where this node runs.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="socket-transport">
        <xs:complexContent>
            <xs:extension base="tns:transport">
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="thread-pool">
        <xs:attribute name="min-threads" type="xs:int" use="optional">
            <xs:annotation>
                <xs:documentation>Minimum thread pool size for the thread pool.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="max-threads" type="xs:int" use="optional">
            <xs:annotation>
                <xs:documentation>Maximum thread pool size for the thread pool.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="keepalive-time" type="xs:long" use="optional">
            <xs:annotation>
                <xs:documentation>Timeout in milliseconds to remove idle thread from the pool.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="property">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="name" type="xs:string" use="required">
                    <xs:annotation>
                        <xs:documentation>Defines the name of a protocol property.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="relay">
        <xs:sequence>
            <xs:element name="remote-site" type="tns:remote-site" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>Defines a remote site to which to bridge.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="site" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>The name of our site.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="remote-site">
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>The name of the remote site.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="channel" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>The bridge channel to this remote site.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:simpleType name="list">
        <xs:list itemType="xs:string"/>
    </xs:simpleType>

</xs:schema>
