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

<!--
  ~ Copyright The WildFly Authors
  ~ SPDX-License-Identifier: Apache-2.0
  -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:jboss:domain:transactions:1.1"
            xmlns="urn:jboss:domain:transactions:1.1"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.1">

    <!-- The transaction subsystem root element -->
    <xs:element name="subsystem" type="subsystem"/>

    <xs:complexType name="subsystem">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The configuration of the transactions subsystem.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:all>
            <xs:element name="core-environment" type="core-environment"/>
            <xs:element name="recovery-environment" type="recovery-environment"/>
            <xs:element name="coordinator-environment" type="coordinator-environment" minOccurs="0"/>
            <xs:element name="object-store" type="object-store" minOccurs="0"/>
            <xs:element name="jts" type="jts-Type" minOccurs="0" maxOccurs="1"/>
        </xs:all>
    </xs:complexType>

    <xs:complexType name="recovery-environment">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The recovery environment configuration.

                The "socket-binding" attribute is used to reference the correct socket binding to use for the
                recovery environment.
                The "status-socket-binding" attribute is used to reference the correct socket binding to use for the
                transaction status manager.
                The "recovery-listener" attribute sets if recovery system should listen on a network socket or not.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="socket-binding" type="xs:string" />
        <xs:attribute name="status-socket-binding" type="xs:string" />
        <xs:attribute name="recovery-listener" type="xs:boolean" default="false"/>
    </xs:complexType>

    <xs:complexType name="core-environment">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The core environment configuration.

                The process-id element specifies the process id implemention.
                The "node-identifier" attribute is used to set the node identifier on the core environment.

                The "path" attribute denotes a relative or absolute filesystem path denoting where the transaction
                manager core should store data.

                The "relative-to" attribute references a global path configuration in the domain model, defaulting
                to the JBoss Application Server data directory (jboss.server.data.dir). If the value of the "path" attribute
                does not specify an absolute pathname, it will treated as relative to this path.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:all>
            <xs:element name="process-id" type="process-id" />
        </xs:all>
        <xs:attribute name="node-identifier" type="xs:string" default="1"/>
        <xs:attribute name="path" type="xs:string" default="var"/>
        <xs:attribute name="relative-to" type="xs:string" default="jboss.server.data.dir"/>
    </xs:complexType>
    <xs:complexType name="process-id">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The process identifer implementation
                The "node-identifier" attribute is used to set the node identifier on the core environment.
                The "socket-process-id-max-ports" attribute is used to set the max ports on the core environment.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:choice>
            <xs:element name="uuid" type="uuid" />
            <xs:element name="socket" type="socket-id" />
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="uuid">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The UUID based process identifer implementation
            ]]>
            </xs:documentation>
        </xs:annotation>
    </xs:complexType>
    <xs:complexType name="socket-id">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The socket based process identifer implementation
                The "socket-binding" attribute is used to specify the port to bind to.
                The "socket-process-id-max-ports" attribute is used to set the max ports on the core environment.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="socket-binding" type="xs:string" use="required"/>
        <xs:attribute name="socket-process-id-max-ports" type="xs:int" default="10" />
    </xs:complexType>

    <xs:attribute name="socket-process-id-max-ports" type="xs:int" default="10" />

    <xs:complexType name="coordinator-environment">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The coordinator environment configuration.
                enable-statistics - if recording of transaction statistics is enabled, false otherwise.
                enable-tsm-status - if the transaction status manager (TSM) service, needed for out of process recovery, should be provided or not.
                default-timeout - the default transaction lifetime, in seconds.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="enable-statistics" type="xs:boolean" default="false"/>
        <xs:attribute name="enable-tsm-status" type="xs:boolean" default="false"/>
        <xs:attribute name="default-timeout" type="xs:int" default="300" />
    </xs:complexType>

    <xs:complexType name="object-store">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The object store configuration.

                The "path" attribute denotes a relative or absolute filesystem path denoting where the transaction
                manager object store should store data.

                The "relative-to" attribute references a global path configuration in the domain model, defaulting
                to the JBoss Application Server data directory (jboss.server.data.dir). If the value of the "path" attribute
                does not specify an absolute pathname, it will treated as relative to this path.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="path" type="xs:string" default="tx-object-store"/>
        <xs:attribute name="relative-to" type="xs:string" default="jboss.server.data.dir" />
    </xs:complexType>

    <xs:complexType name="jts-Type">
        <xs:annotation>
            <xs:documentation>
            <![CDATA[
                The flag to enable JTS.
            ]]>
            </xs:documentation>
        </xs:annotation>
    </xs:complexType>

</xs:schema>
