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

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2022, 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:distributable-ejb:1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="urn:jboss:domain:distributable-ejb:1.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           version="1.0">

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

    <xs:complexType name="subsystem">
        <xs:sequence>
            <xs:choice maxOccurs="unbounded">
                <xs:element name="infinispan-bean-management" type="tns:infinispan-bean-management">
                    <xs:annotation>
                        <xs:documentation>An Infinispan-based bean management provider</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:choice>
            <xs:choice>
                <xs:element name="local-client-mappings-registry" type="tns:empty">
                    <xs:annotation>
                        <xs:documentation>Configures support for local client mappings registry</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="infinispan-client-mappings-registry" type="tns:infinispan-client-mappings-registry">
                    <xs:annotation>
                        <xs:documentation>Configures support for cluster-aware client mappings registry</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:choice>
            <xs:choice maxOccurs="unbounded">
                <xs:element name="infinispan-timer-management" type="tns:infinispan-timer-management">
                    <xs:annotation>
                        <xs:documentation>References an existing timer management provider</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="default-bean-management" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>Identifies the default bean management provider for ejb applications.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="infinispan-bean-management">
        <xs:attribute name="name" type="xs:string">
            <xs:annotation>
                <xs:documentation>The name of this bean management provider</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attributeGroup ref="tns:infinispan"/>
        <xs:attribute name="max-active-beans" type="xs:string">
            <xs:annotation>
                <xs:documentation>The maximum number active beans to retain in memory at a time, after which the least recently used will passivate.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="infinispan-client-mappings-registry">
        <xs:attributeGroup ref="tns:infinispan"/>
    </xs:complexType>

    <xs:attributeGroup name="infinispan">
        <xs:attribute name="cache-container" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>References a cache-container defined by the Infinispan subsystem.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="cache" type="xs:string">
            <xs:annotation>
                <xs:documentation>
                    References a cache within the associated cache-container.
                    If unspecified, the default cache of the associated cache-container is assumed.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:complexType name="infinispan-timer-management">
        <xs:attribute name="name" type="xs:string">
            <xs:annotation>
                <xs:documentation>References the name of an existing bean management provider</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attributeGroup ref="tns:infinispan"/>
        <xs:attribute name="max-active-timers" type="xs:integer">
            <xs:annotation>
                <xs:documentation>The maximum number active timers to retain in memory at a time, after which the least recently used will passivate.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="marshaller" type="tns:marshaller" default="JBOSS">
            <xs:annotation>
                <xs:documentation>Indicates the marshalling implementation used for serializing the timeout context of a timer.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="empty">
        <xs:sequence/>
    </xs:complexType>

    <xs:simpleType name="marshaller">
        <xs:restriction base="xs:token">
            <xs:enumeration value="JBOSS">
                <xs:annotation>
                    <xs:documentation>
                        Marshaller based on JBoss Marshalling.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="PROTOSTREAM">
                <xs:annotation>
                    <xs:documentation>
                        Marshaller based on ProtoStream.
                    </xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
