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

<!--
  ~ Copyright The WildFly Authors
  ~ SPDX-License-Identifier: Apache-2.0
  -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:jboss:ejb-client:1.1"
            xmlns="urn:jboss:ejb-client:1.1"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.1">

    <!-- Root element -->
    <xsd:element name="jboss-ejb-client" type="jboss-ejb-clientType">
        <xsd:annotation>
            <xsd:documentation>
                Root element for a jboss-ejb-client.xml file
            </xsd:documentation>
        </xsd:annotation>
    </xsd:element>

    <xsd:complexType name="jboss-ejb-clientType">
        <xsd:annotation>
            <xsd:documentation>
                The EJB client configurations
            </xsd:documentation>
        </xsd:annotation>
        <xsd:all>
            <xsd:element name="client-context" type="client-contextType">
                <xsd:annotation>
                    <xsd:documentation>
                        Configurations that will be used to setup an EJB client context for the
                        deployment.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:all>

    </xsd:complexType>

    <xsd:complexType name="client-contextType">
        <xsd:all>
            <xsd:element name="ejb-receivers" type="ejb-receiversType">
                <xsd:annotation>
                    <xsd:documentation>
                        Configures EJB receivers for the client context
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="clusters" type="clustersType" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Cluster configurations applicable for this client context
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="ejb-receiversType">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="remoting-ejb-receiver" type="remoting-ejb-receiverType">
                <xsd:annotation>
                    <xsd:documentation>
                        Configures a remoting based EJB receiver
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:choice>
        <xsd:attribute name="exclude-local-receiver" type="xsd:boolean" use="optional" default="false">
            <xsd:annotation>
                <xsd:documentation>
                    Set to true if the local receiver which gets added to the EJB client context by default, has to be
                    excluded from the context
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="local-receiver-pass-by-value" type="xsd:boolean" use="optional" default="true">
            <xsd:annotation>
                <xsd:documentation>
                    Set to false if the local receiver that's available in the EJB client context, should use
                    pass-by-reference (instead of pass-by-value) semantics for the EJB invocations.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:complexType>


    <xsd:complexType name="remoting-ejb-receiverType">
        <xsd:attribute name="outbound-connection-ref" type="xsd:string" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    Reference to an outbound connection configured in the remoting subsystem
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name="clustersType">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="cluster" type="clusterType">
                <xsd:annotation>
                    <xsd:documentation>
                        Configures a cluster in the client context
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="clusterType">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="channel-creation-options" type="channel-creation-optionsType" maxOccurs="1">
                <xsd:annotation>
                    <xsd:documentation>
                        Configures the channel creation options for the nodes in this cluster
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="connection-creation-options" type="connection-creation-optionsType" maxOccurs="1">
                <xsd:annotation>
                    <xsd:documentation>
                        Configures the connection creation options for the nodes in this cluster
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="node" type="clusterNodeType" maxOccurs="unbounded">
                <xsd:annotation>
                    <xsd:documentation>
                        Configures the channel creation options for the nodes in this cluster
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:choice>
        <xsd:attribute name="name" type="xsd:string" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    The name of the cluster
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="connect-timeout" type="xsd:long" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    The timeout in milliseconds while creating a connection for the nodes in the cluster
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="max-allowed-connected-nodes" type="xsd:long" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    The maximum number of nodes to which the connection will be established in the cluster
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="cluster-node-selector" type="xsd:string" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    The fully qualified class name of the class which implements the
                    org.jboss.ejb.client.ClusterNodeSelector
                    interface. The instance of this class will be used for selecting nodes, within the cluster, for
                    handling invocations
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="username" type="xsd:string" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    This attribute is no longer supported and must be removed from the configuration.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="security-realm" type="xsd:string" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    This attribute is no longer supported and must be removed from the configuration.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name="clusterNodeType">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="channel-creation-options" type="channel-creation-optionsType" maxOccurs="1">
                <xsd:annotation>
                    <xsd:documentation>
                        Configures the channel creation options for the node
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="connection-creation-options" type="connection-creation-optionsType" maxOccurs="1">
                <xsd:annotation>
                    <xsd:documentation>
                        Configures the connection creation options for the node
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:choice>
        <xsd:attribute name="name" type="xsd:string" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    The name of the cluster node
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="connect-timeout" type="xsd:long" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    The timeout in milliseconds while creating a connection for the node
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="username" type="xsd:string" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    This attribute is no longer supported and must be removed from the configuration.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="security-realm" type="xsd:string" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    This attribute is no longer supported and must be removed from the configuration.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name="channel-creation-optionsType">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="property" type="propertyType"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="connection-creation-optionsType">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="property" type="propertyType"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="propertyType">
        <xsd:attribute name="name" type="xsd:string" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    The name of the property. Example org.xnio.Options.SASL_POLICY_NOANONYMOUS
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="value" type="xsd:string" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    The value of the property.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>

    </xsd:complexType>
</xsd:schema>

