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

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2011, 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"
            targetNamespace="urn:jboss:domain:transactions:1.2"
            xmlns="urn:jboss:domain:transactions:1.2"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.2">

    <!-- 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:element name="use-hornetq-store" type="use-hornetq-store-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:complexType name="use-hornetq-store-Type">
            <xs:annotation>
                <xs:documentation>
                <![CDATA[
                    The flag to enable the hornetq transaction log store.
                ]]>
                </xs:documentation>
            </xs:annotation>
    </xs:complexType>

</xs:schema>
