<?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:resource-adapters:5.0" xmlns="urn:jboss:domain:resource-adapters:5.0"
           xmlns:credential-reference="urn:wildfly:credential-reference:1.0"
           elementFormDefault="qualified" attributeFormDefault="unqualified">

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

  <xs:element name="subsystem" type="subsystemType"/>

  <xs:complexType name="subsystemType">
    <xs:all>
      <xs:element name="resource-adapters" type="resource-adaptersType" minOccurs="0" maxOccurs="1"/>
    </xs:all>
  </xs:complexType>

  <xs:complexType name="boolean-presenceType"></xs:complexType>

  <xs:complexType name="config-propertyType" mixed="true">
    <xs:annotation>
      <xs:documentation>
        <![CDATA[[
          Specifies an override for a config-property element in ra.xml or a @ConfigProperty
         ]]>
      </xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:token">
        <xs:attribute use="required" name="name" type="xs:token">
          <xs:annotation>
            <xs:documentation>
              <![CDATA[[
                Specifies the name of the config-property
               ]]>
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:complexType name="resource-adapterType">
    <xs:sequence>
      <xs:element name="archive" type="xs:token" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the resource adapter archive to be activated
              E.g. <archive>myra.rar</archive>
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
        <xs:element name="module" type="moduleType" minOccurs="0" maxOccurs="1">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[[
                      Specifies the resource adapter module to be activated
                      E.g. <archive>org.jboss.ironjacamar.ra16out</archive>
                     ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:element>
        <xs:element name="bean-validation-groups" type="bean-validation-groupsType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies bean validation group that should be used
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="bootstrap-context" type="xs:token" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the unique name of the bootstrap context that should be used
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="config-property" type="config-propertyType" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
               The config-property specifies resource adapter configuration properties.
              ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="transaction-support" type="transaction-supportType" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the transaction support level of the resource adapter
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="workmanager" type="workmanagerType" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                    Specifies the settings for the WorkManager used by this resource adapter
                   ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="connection-definitions" type="connection-definitionsType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the connection definitions
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="admin-objects" type="admin-objectsType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the administration objects
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="id" type="xs:token" use="required">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            An unique identifier for the resource adapter
                        ]]>
          </xs:documentation>
        </xs:annotation>
    </xs:attribute>
    <xs:attribute default="false" name="statistics-enabled" type="xs:boolean">
          <xs:annotation>
            <xs:documentation>
                <![CDATA[[
                      Enable statistics for this resource-adapter
                     ]]>
            </xs:documentation>
          </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:simpleType name="transaction-supportType">
    <xs:annotation>
      <xs:documentation>
        <![CDATA[[
          Define the type of transaction supported by this resource adapter.
          Valid values are: NoTransaction, LocalTransaction, XATransaction
         ]]>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="NoTransaction" />
      <xs:enumeration value="LocalTransaction" />
      <xs:enumeration value="XATransaction" />
    </xs:restriction>
  </xs:simpleType>

  <xs:attributeGroup name="common-attribute">
    <xs:attribute name="class-name" type="xs:token" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Specifies the the fully qualified class name of a managed connection factory
            or admin object
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="jndi-name" type="xs:token" use="required">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Specifies the JNDI name
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="enabled" type="xs:boolean" default="true" form="unqualified" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Should the object in question be activated
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute default="true" name="use-java-context" type="xs:boolean">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Specifies if a java:/ JNDI context should be used
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="pool-name" type="xs:token" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Specifies the pool name for the object
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:attributeGroup>

  <xs:complexType name="admin-objectType">
    <xs:sequence>
      <xs:element name="config-property" type="config-propertyType" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              The config-property specifies administration object configuration properties.
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attributeGroup ref="common-attribute"></xs:attributeGroup>
  </xs:complexType>

  <xs:complexType name="timeoutType">
    <xs:sequence>
      <xs:element name="blocking-timeout-millis" type="xs:nonNegativeInteger" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                The blocking-timeout-millis element indicates the maximum time in
                milliseconds to block while waiting for a connection before throwing an exception.
                Note that this blocks only while waiting for a permit for a connection, and
                will never throw an exception if creating a new connection takes an inordinately
                long time. The default is 30000 (30 seconds).
              ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="idle-timeout-minutes" type="xs:nonNegativeInteger" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              The idle-timeout-minutes elements indicates the maximum time in minutes
              a connection may be idle before being closed. The actual maximum time depends
              also on the IdleRemover scan time, which is 1/2 the smallest idle-timeout-minutes
              of any pool.
              ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="allocation-retry" type="xs:nonNegativeInteger" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              The allocation retry element indicates the number of times that allocating
              a connection should be tried before throwing an exception. The default is
              0.
              ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="allocation-retry-wait-millis" type="xs:nonNegativeInteger" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              The allocation retry wait millis element indicates the time in milliseconds
              to wait between retrying to allocate a connection. The default is 5000 (5
              seconds).
              ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="xa-resource-timeout" type="xs:nonNegativeInteger" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Passed to XAResource.setTransactionTimeout(). Default is zero which does not invoke the setter.
              Specified in seconds - e.g. 5 minutes
              <xa-resource-timeout>300</xa-resource-timeout>
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="validationType">
    <xs:sequence>
      <xs:element name="validate-on-match" type="xs:boolean" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              The validate-on-match element indicates whether or not connection
              level validation should be done when a connection factory attempts to match
              a managed connection for a given set. This is typically exclusive to the
              use of background validation
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="background-validation" type="xs:boolean" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              An element to specify that connections should be validated on a background
              thread versus being validated prior to use
              ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="background-validation-millis" type="xs:nonNegativeInteger" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
               The background-validation-millis element specifies the amount of
               time, in millis, that background validation will run.
              ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="use-fast-fail" type="xs:boolean" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                Whether fail a connection allocation on the first connection if it
                is invalid (true) or keep trying until the pool is exhausted of all potential
                connections (false) default false. e.g. <use-fast-fail>true</use-fast-fail>
              ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="resource-adaptersType">
    <xs:sequence>
      <xs:element name="resource-adapter" type="resource-adapterType" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies activation of a resource adapter
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="connection-definitionsType">
    <xs:sequence>
      <xs:element name="connection-definition" type="connection-defintionType" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies a connection definition
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="connection-defintionType">
    <xs:sequence>
      <xs:element name="config-property" type="config-propertyType" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
             The config-property specifies managed connection factory configuration properties.
            ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:choice>
        <xs:element name="pool" type="poolType" minOccurs="0" maxOccurs="1">
          <xs:annotation>
            <xs:documentation>
                <![CDATA[[
                  Specifies pooling settings
                 ]]>
            </xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="xa-pool" type="xa-poolType" minOccurs="0" maxOccurs="1">
          <xs:annotation>
            <xs:documentation>
                <![CDATA[[
                  Specifies xa-pooling settings
                 ]]>
            </xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:choice>
      <xs:element name="security" type="securityType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies security settings
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="timeout" type="timeoutType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies timeout settings
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="validation" type="validationType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies validation settings
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="recovery" type="recoverType" minOccurs="0" maxOccurs="1"></xs:element>
    </xs:sequence>
    <xs:attribute name="use-ccm" type="xs:boolean" default="true" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Enable cached connection manager
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sharable" type="xs:boolean" default="true" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
                Defines the connections as sharable which allows lazy association to be enabled
                if supported
               ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="enlistment" type="xs:boolean" default="true" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
                Defines if lazy enlistment should be used if supported by the resource adapter
               ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute default="false" name="connectable" type="xs:boolean">
      <xs:annotation>
        <xs:documentation>
            <![CDATA[[
                 Enable CMR functionality on this connection
                ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="tracking" type="xs:boolean" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Defines if IronJacamar should track connection handles across transaction boundaries
          ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="mcp" type="xs:token" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Defines the ManagedConnectionPool implementation, f.ex. org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="enlistment-trace" type="xs:boolean" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Defines if WildFly/IronJacamar should record enlistment traces
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attributeGroup ref="common-attribute"></xs:attributeGroup>
  </xs:complexType>

  <xs:complexType name="poolType">
    <xs:sequence>
      <xs:element name="min-pool-size" type="xs:nonNegativeInteger" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              The min-pool-size element indicates the minimum number of connections
              a pool should hold. These are not created until a Subject is known from a
              request for a connection. This default to 0. Ex: <min-pool-size>1</min-pool-size>
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="initial-pool-size" type="xs:nonNegativeInteger" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                    The initial-pool-size element indicates the initial number of connections
                    a pool should hold. This default to 0. Ex: <initial-pool-size>1</initial-pool-size>
                   ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="max-pool-size" type="xs:nonNegativeInteger" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              The max-pool-size element indicates the maximum number of connections
              for a pool. No more than max-pool-size connections will be created in each sub-pool.
              This defaults to 20.
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="prefill" type="xs:boolean" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Whether to attempt to prefill the connection pool. Default is false.
              e.g. <prefill>false</prefill>.
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="fair" type="xs:boolean" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Defines if pool use should be fair
              Default true
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="use-strict-min" type="xs:boolean" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Define if the min-pool-size should be considered strict.
              Default false
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="flush-strategy" type="xs:token" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies how the pool should be flush in case of an error.
              Valid values are: FailingConnectionOnly (default), InvalidIdleConnections, IdleConnections, Gracefully, EntirePool,
                                              AllInvalidIdleConnections, AllIdleConnections, AllGracefully, AllConnections
                           ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="capacity" type="capacityType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                            Specifies the capacity policies for the pool
                           ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="xa-poolType">
    <xs:complexContent>
      <xs:extension base="poolType">
        <xs:sequence>
          <xs:element name="is-same-rm-override" type="xs:boolean" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                <![CDATA[[
                  The is-same-rm-override element allows one to unconditionally
                  set whether the javax.transaction.xa.XAResource.isSameRM(XAResource) returns
                  true or false. Ex: <is-same-rm-override>true</is-same-rm-override>
                 ]]>
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="interleaving" type="boolean-presenceType" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                <![CDATA[[
                  An element to enable interleaving for XA connection factories
                  Ex: <interleaving/>
                 ]]>
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="no-tx-separate-pools" type="boolean-presenceType" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                <![CDATA[[
                  Oracle does not like XA connections getting used both inside and outside a JTA transaction.
                  To workaround the problem you can create separate sub-pools for the different contexts
                  using <no-tx-separate-pools/>
                  Ex: <no-tx-separate-pools/>
                 ]]>
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="pad-xid" type="xs:boolean" default="false" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                <![CDATA[[
                   Should the Xid be padded
                   Ex: <pad-xid>true</pad-xid>
                 ]]>
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="wrap-xa-resource" type="xs:boolean" default="true" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                <![CDATA[[
                   Should the XAResource instances be wrapped in an org.jboss.tm.XAResourceWrapper
                   instance
                   Ex: <wrap-xa-resource>true</wrap-xa-resource>
                 ]]>
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="securityType">
    <xs:sequence>
      <xs:choice>
        <xs:element name="application" type="boolean-presenceType" minOccurs="0" maxOccurs="1">
          <xs:annotation>
            <xs:documentation>
              <![CDATA[[
                Indicates that app supplied parameters (such as from getConnection(user, pw))
                are used to distinguish connections in the pool.
                Ex:
                <application/>
              ]]>
            </xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="security-domain" type="xs:token" minOccurs="0" maxOccurs="1">
          <xs:annotation>
            <xs:documentation>
              <![CDATA[[
                Indicates Subject (from security domain) are used to distinguish connections in the pool.
                The content of the security-domain is the name of the JAAS security manager that will handle
                authentication. This name correlates to the JAAS login-config.xml descriptor
                application-policy/name attribute.
                Ex:
                <security-domain>HsqlDbRealm</security-domain>
              ]]>
            </xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="security-domain-and-application" type="xs:token" minOccurs="0" maxOccurs="1">
          <xs:annotation>
            <xs:documentation>
              <![CDATA[[
                Indicates that either app supplied parameters (such as from
                getConnection(user, pw)) or Subject (from security domain) are used to
                distinguish connections in the pool. The content of the
                security-domain is the name of the JAAS security manager that will handle
                authentication. This name correlates to the JAAS login-config.xml descriptor
                application-policy/name attribute.

                Ex:
                <security-domain-and-application>HsqlDbRealm</security-domain-and-application>
              ]]>
            </xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:sequence minOccurs="0" maxOccurs="1">
          <xs:element name="elytron-enabled" type="boolean-presenceType" minOccurs="1">
            <xs:annotation>
              <xs:documentation>
                <![CDATA[[
                Indicates that Elytron is responsible for authenticating connections. If authentication-context
                is configured (via either authentication-context or authentication-context-and-application),
                Elytron will use that specified context for authenticating. Else, Elytron will use the
                current authentication context of the caller that is retrieving the connection.
                Ex:
                <elytron-enabled/>
              ]]>
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:choice minOccurs="0" maxOccurs="1">
            <xs:element name="authentication-context" type="xs:token">
              <xs:annotation>
                <xs:documentation>
                  <![CDATA[[
                  Indicates the Elytron context that will be used for authenticating connections during
                  container-managed sign-on.
                  The resulting Subject will be used to distinguish connections in the pool.
                  The authentication-context name correlates to the authentication context defined in
                  the Elytron subsystem.
                  Ex:
                    <elytron-enabled/>
                    <authentication-context>HsqlDbContext</authentication-context>
                  ]]>
                </xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element name="authentication-context-and-application" type="xs:token">
              <xs:annotation>
                <xs:documentation>
                  <![CDATA[[
                  Indicates that either app supplied parameters (such as from
                  getConnection(user, pw)) or an authenticated Subject (resulting of container-managed sign-on
                  authentication) are used to distinguish connections in the pool.
                  The authentication-context name correlates to the authentication context defined in
                  the Elytron subsystem.
                  Ex:
                    </elytron-enabled/>
                    <authentication-context-and-application>HsqlDbContext</authentication-context-and-application>
                  ]]>
                </xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:choice>
        </xs:sequence>
      </xs:choice>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="admin-objectsType">
    <xs:sequence>
      <xs:element name="admin-object" type="admin-objectType" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the setup for an admin object
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="bean-validation-groupsType">
    <xs:sequence>
      <xs:element name="bean-validation-group" type="xs:token" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the fully qualified class name for a bean validation group that
              should be used for validation
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="recoverType">
    <xs:sequence>
      <xs:element name="recover-credential" type="credentialType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the security options used when creating a connection during recovery.
              Note: if this credential is not specified the security credential is used for recovery too
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="recover-plugin" type="extensionType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
              Specifies the extension plugin used in spi (core.spi.xa)
              which can be implemented by various plugins to provide better feedback to the XA recovery system.
             ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="no-recovery" type="xs:boolean" default="false" use="optional">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
            Specify if the xa-datasource should be excluded from recovery.
            Default false.
           ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
  <xs:complexType name="extensionType">
    <xs:sequence>
      <xs:element name="config-property" type="config-propertyType"></xs:element>
    </xs:sequence>
    <xs:attribute name="class-name" type="xs:token" use="required"></xs:attribute>
  </xs:complexType>
  <xs:complexType name="credentialType">
    <xs:sequence>
      <xs:element name="user-name" type="xs:token" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
              <![CDATA[[
                Specify the username used when creating a new connection.
                Ex: <user-name>sa</user-name>
               ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="password" type="xs:token" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
              <![CDATA[[
                Specify the password used when creating a new connection.
                Ex: <password>sa-pass</password>
               ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="credential-reference" type="credential-reference:credentialReferenceType" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Credential to be used by the configuration.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:choice minOccurs="0">
        <xs:element name="security-domain" type="xs:token">
          <xs:annotation>
            <xs:documentation>
              <![CDATA[[
              Indicates Subject (from security domain) are used to distinguish connections in the pool.
              The content of the security-domain is the name of the JAAS security manager that will handle
              authentication. This name correlates to the JAAS login-config.xml descriptor
              application-policy/name attribute.
              Ex:
                <security-domain>HsqlDbRealm</security-domain>
              ]]>
            </xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:sequence>
          <xs:element name="elytron-enabled" type="boolean-presenceType">
            <xs:annotation>
              <xs:documentation>
                <![CDATA[[
                Indicates that Elytron is responsible for authenticating connections. If authentication-context
                is configured (via authentication-context), Elytron will use that specified context for authenticating.
                Else, Elytron will use the current authentication context of the caller that is retrieving the connection.
                Ex:
                  <elytron-enabled/>
                ]]>
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="authentication-context" type="xs:token" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                <![CDATA[[
                Indicates the Elytron context that will be used for authenticating connections during
                container-managed sign-on.
                The resulting Subject will be used to distinguish connections in the pool.
                The authentication-context name correlates to the authentication context defined in
                the Elytron subsystem.
                Ex:
                <elytron-enabled/>
                <authentication-context>HsqlDbContext</authentication-context>
            ]]>
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:choice>
    </xs:sequence>
   </xs:complexType>

   <xs:complexType name="moduleType">
       <xs:attribute name="id" type="xs:token" use="required">
           <xs:annotation>
               <xs:documentation>
                   <![CDATA[[
                   The module id
                               ]]>
               </xs:documentation>
           </xs:annotation>
       </xs:attribute>
       <xs:attribute name="slot" type="xs:token" use="optional">
             <xs:annotation>
               <xs:documentation>
                 <![CDATA[[
                   The module slot
                               ]]>
                 </xs:documentation>
               </xs:annotation>
           </xs:attribute>
   </xs:complexType>

  <xs:complexType name="workmanagerType">
    <xs:sequence>
      <xs:element name="security" type="workmanagerSecurityType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Defines the security model used by the WorkManager instance
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="workmanagerSecurityType">
    <xs:sequence>
      <xs:element name="mapping-required" type="xs:boolean" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Defines if a mapping is required for security credentials. A value of false means
                  "Case 1" as defined in section 16.4.3, and a value of true means "Case 2" as
                  defined in section 16.4.4.
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="domain" type="xs:token" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Defines the name of the security domain that should be used
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="elytron-security-domain" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Indicates that Elytron is responsible for WorkManager security. It defines the name of the Elytron
                  security domain that should be used
                  Ex:
                    <elytron-security-domain>ApplicationDomain</elytron-security-domain>
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="default-principal" type="xs:token" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Defines a default principal name that should be added to the used Subject instance
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="default-groups" type="workmanagerSecurityGroupsType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Defines a default groups that should be added to the used Subject instance
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="mappings" type="workmanagerSecurityMappingsType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Defines the mappings that should be applied for Case 2
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="workmanagerSecurityGroupsType">
    <xs:sequence>
      <xs:element name="group" type="xs:token" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  The name of the group
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="workmanagerSecurityMappingsType">
    <xs:sequence>
      <xs:element name="users" type="workmanagerSecurityMappingsUsersType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  The mappings for the users
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="groups" type="workmanagerSecurityMappingsGroupsType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  The mappings for the groups
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="workmanagerSecurityMappingsUsersType">
    <xs:sequence>
      <xs:element name="map" type="workmanagerSecurityMappingType" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  A user mapping
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="workmanagerSecurityMappingsGroupsType">
    <xs:sequence>
      <xs:element name="map" type="workmanagerSecurityMappingType" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  A group mapping
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="workmanagerSecurityMappingType">
    <xs:sequence>
    </xs:sequence>
    <xs:attribute name="from" type="xs:token" use="required">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
                Specify the original value
               ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="to" type="xs:token" use="required">
      <xs:annotation>
        <xs:documentation>
          <![CDATA[[
                Specify the mapped value
               ]]>
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="capacityType">
    <xs:sequence>
      <xs:element name="incrementer" type="extensionType" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Defines the policy for incrementing connections in the pool
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="decrementer" type="extensionType" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            <![CDATA[[
                  Defines the policy for decrementing connections in the pool
                 ]]>
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

</xs:schema>
