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

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2015, 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:batch-jberet:1.0"
           targetNamespace="urn:jboss:batch-jberet:1.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           version="1.0">

    <!-- The deployment descriptor root element -->
    <xs:element name="batch" type="batchType"/>

    <xs:complexType name="batchType">
        <xs:annotation>
            <xs:documentation>
                <![CDATA[
                The batch environment configuration for the deployment.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="restart-jobs-on-resume" type="booleanType" minOccurs="0" maxOccurs="1">
                <xs:annotation>
                    <xs:documentation>
                        If set to true when a resume operation has be invoked after a suspend operation any jobs stopped
                        during the suspend will be restarted. A value of false will leave the jobs in a stopped state.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="job-repository" type="job-repositoryType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="thread-pool" type="namedType" minOccurs="0" maxOccurs="1">
                <xs:annotation>
                    <xs:documentation>
                        <![CDATA[
                        Specify the name of the thread-pool to use defined in the batch-jberet subsystem.
                        ]]>
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="namedType">
        <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>

    <xs:complexType name="booleanType">
        <xs:attribute name="value" type="xs:boolean" use="optional"/>
    </xs:complexType>

    <xs:complexType name="job-repositoryType">
        <xs:annotation>
            <xs:documentation>
                <![CDATA[
                The name of the job repository to use
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="in-memory" type="in-memoryType"/>
            <xs:element name="named" type="namedType">
                <xs:annotation>
                    <xs:documentation>
                        <![CDATA[
                        Indicates the name of the job repository defined on the subsystem to use.
                        ]]>
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:choice>
    </xs:complexType>

    <xs:complexType name="in-memoryType">
        <xs:annotation>
            <xs:documentation>
                <![CDATA[
                        Used to describe an in-memory job repository.
                ]]>
            </xs:documentation>
        </xs:annotation>
    </xs:complexType>
</xs:schema>
