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

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2017 Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:jboss:wildfly-client-ejb:3.0"
            xmlns="urn:jboss:wildfly-client-ejb:3.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0">

    <!-- Root elements -->

    <xsd:element name="jboss-ejb-client" type="ejb-client-type"/>

    <!-- Types -->

    <xsd:complexType name="ejb-client-type">
        <xsd:annotation>
            <xsd:documentation>
                Container for EJB client configuration.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:all minOccurs="1" maxOccurs="1">
            <xsd:element name="invocation-timeout" type="invocation-timeout-type" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="global-interceptors" type="interceptors-type" minOccurs="0" maxOccurs="1">
                <xsd:annotation>
                    <xsd:documentation>
                        Container for global EJB client interceptor definitions.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="connections" type="connections-type" minOccurs="0" maxOccurs="1"/>
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="invocation-timeout-type">
        <xsd:annotation>
            <xsd:documentation>
                Definition of an EJB invocation timeout.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:attribute name="seconds" type="xsd:integer" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    The timeout, in seconds, for the EJB handshake or method invocation request/response cycle.
                    The invocation of any method throws a java.util.concurrent.TimeoutException if the execution
                    takes longer than the timeout period. The server side will not be interrupted.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:complexType>

    <!-- Interceptors -->

    <xsd:complexType name="interceptors-type">
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="interceptor" type="interceptor-type"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="interceptor-type">
        <xsd:annotation>
            <xsd:documentation>
                Definition of an EJB client interceptor.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:attribute name="class" type="xsd:string" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    The name of a class that implements the org.jboss.ejb.client.EJBClientInterceptor interface.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="module" type="xsd:string" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    The name of the module that should be used to load the interceptor class.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:complexType>

    <!-- Connections -->

    <xsd:complexType name="connections-type">
        <xsd:annotation>
            <xsd:documentation>
                Container for EJB client connection definitions.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="connection" type="connection-type"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:complexType name="connection-type">
        <xsd:annotation>
            <xsd:documentation>
                Definition of an EJB client connection.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:all minOccurs="1" maxOccurs="1">
            <xsd:element name="interceptors" type="interceptors-type" minOccurs="0" maxOccurs="1">
                <xsd:annotation>
                    <xsd:documentation>
                        Container for EJB client interceptor definitions.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:all>
        <xsd:attribute name="uri" type="xsd:anyURI" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    The connection destination URI.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:complexType>
</xsd:schema>