<?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 @authors tag.
~
~ 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.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="https://jakarta.ee/xml/ns/jakartaee"
           xmlns:jakartaee="https://jakarta.ee/xml/ns/jakartaee"
           xmlns:jboss="urn:jboss:jakartaee:1.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           version="4.0">

   <!-- xs:include schemaLocation="ejb-jar_4_0.xsd"/ -->
   <!--
   <xs:include schemaLocation="https://jakarta.ee/xml/ns/jakartaee/ejb-jar_4_0.xsd"/>
   -->

   <xs:import namespace="urn:jboss:jakartaee:1.0"/>

   <xs:redefine schemaLocation="https://jakarta.ee/xml/ns/jakartaee/ejb-jar_4_0.xsd">
      <xs:complexType name="assembly-descriptorType">
         <xs:complexContent>
            <xs:extension base="jakartaee:assembly-descriptorType">
               <xs:sequence>
                  <xs:element ref="jakartaee:assembly-descriptor-entry" minOccurs="0" maxOccurs="unbounded"/>
               </xs:sequence>
            </xs:extension>
         </xs:complexContent>
      </xs:complexType>
   </xs:redefine>

   <xs:redefine schemaLocation="https://jakarta.ee/xml/ns/jakartaee/ejb-jar_4_0.xsd">
      <xs:complexType name="container-transactionType">
         <xs:complexContent>
            <xs:extension base="jakartaee:container-transactionType">
               <xs:sequence>
                  <xs:element ref="jakartaee:container-transaction-entry" minOccurs="0" maxOccurs="unbounded"/>
               </xs:sequence>
            </xs:extension>
         </xs:complexContent>
      </xs:complexType>
   </xs:redefine>

   <xs:element name="assembly-descriptor-entry" abstract="true" type="jakartaee:jboss-assembly-descriptor-entryType"/>

   <xs:complexType abstract="true" name="jboss-assembly-descriptor-entryType">
      <xs:sequence>
         <xs:element name="description"
                     type="jakartaee:descriptionType"
                     minOccurs="0"
                     maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>

   <xs:complexType name="jboss-assembly-descriptor-bean-entryType">
      <xs:complexContent>
         <xs:extension base="jakartaee:jboss-assembly-descriptor-entryType">
            <xs:sequence>
               <xs:element name="ejb-name"
                           type="jakartaee:string"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <xs:complexType name="jboss-assembly-descriptor-bean-method-entryType">
      <xs:complexContent>
         <xs:extension base="jakartaee:jboss-assembly-descriptor-bean-entryType">
            <xs:sequence>
               <xs:element name="method"
                           type="jakartaee:named-methodType"
                           minOccurs="0"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <xs:complexType name="jboss-assembly-descriptor-method-entryType">
      <xs:complexContent>
         <xs:extension base="jakartaee:jboss-assembly-descriptor-entryType">
            <xs:sequence>
               <xs:element name="method"
                           type="jakartaee:methodType"
                           maxOccurs="unbounded"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <xs:element name="container-transaction-entry" abstract="true" type="jakartaee:jboss-container-transaction-entryType"/>

   <xs:complexType abstract="true" name="jboss-container-transaction-entryType"/>

   <xs:complexType name="jboss-ejb-beanType">
      <xs:sequence>
         <xs:group ref="jakartaee:descriptionGroup"/>
         <xs:element name="ejb-name"
                     type="jakartaee:ejb-nameType"/>
         <xs:element name="mapped-name"
                     type="jakartaee:xsdStringType"
                     minOccurs="0"/>
         <xs:group ref="jakartaee:jndiEnvironmentRefsGroup"/>
      </xs:sequence>
   </xs:complexType>

   <xs:complexType name="jboss-ejb-jarType">
      <xs:complexContent>
         <xs:extension base="jakartaee:ejb-jarType">
            <xs:sequence>
               <xs:element ref="jboss:enterprise-beans" minOccurs="0"/>
            </xs:sequence>
            <xs:attribute name="impl-version" type="jakartaee:dewey-versionType" fixed="2.0" use="required"/>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <!--
      The standard enterprise-beansType starts with a choice which mandates at least one element.
      This effectively makes it non-extensible.
   -->
   <xs:complexType name="jboss-enterprise-beansType">
      <!--
      <xs:complexContent>
         <xs:extension base="jakartaee:enterprise-beansType">
            <xs:choice maxOccurs="unbounded">
               <xs:element ref="jboss:ejb" minOccurs="0" maxOccurs="unbounded"/>
            </xs:choice>
         </xs:extension>
      </xs:complexContent>
      -->
      <xs:annotation>
        <xs:documentation>

          The enterprise-beansType declares one or more enterprise
          beans. Each bean can be a session, entity or message-driven
          bean.

        </xs:documentation>
      </xs:annotation>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="jboss:ejb"/>
        <xs:element name="session"
                     type="jakartaee:session-beanType">
          <!--
          <xs:unique name="session-ejb-local-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The ejb-ref-name element contains the name of
                an EJB reference. The EJB reference is an entry in
                the component's environment and is relative to the
                java:comp/env context.  The name must be unique within
                the component.

                It is recommended that name be prefixed with "ejb/".

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:ejb-local-ref"/>
            <xs:field xpath="jakartaee:ejb-ref-name"/>
          </xs:unique>
          <xs:unique name="session-ejb-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The ejb-ref-name element contains the name of an EJB
                reference. The EJB reference is an entry in the
                component's environment and is relative to the
                java:comp/env context. The name must be unique
                within the component.

                It is recommended that name is prefixed with "ejb/".

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:ejb-ref"/>
            <xs:field xpath="jakartaee:ejb-ref-name"/>
          </xs:unique>
          <xs:unique name="session-resource-env-ref-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The resource-env-ref-name element specifies the name
                of a resource environment reference; its value is
                the environment entry name used in the component
                code. The name is a JNDI name relative to the
                java:comp/env context and must be unique within an
                component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:resource-env-ref"/>
            <xs:field xpath="jakartaee:resource-env-ref-name"/>
          </xs:unique>
          <xs:unique name="session-message-destination-ref-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The message-destination-ref-name element specifies the name
                of a message destination reference; its value is
                the message destination reference name used in the component
                code. The name is a JNDI name relative to the
                java:comp/env context and must be unique within an
                component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:message-destination-ref"/>
            <xs:field xpath="jakartaee:message-destination-ref-name"/>
          </xs:unique>
          <xs:unique name="session-res-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The res-ref-name element specifies the name of a
                resource manager connection factory reference.  The name
                is a JNDI name relative to the java:comp/env context.
                The name must be unique within an component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:resource-ref"/>
            <xs:field xpath="jakartaee:res-ref-name"/>
          </xs:unique>
          <xs:unique name="session-env-entry-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The env-entry-name element contains the name of a
                component's environment entry.  The name is a JNDI
                name relative to the java:comp/env context.  The
                name must be unique within an component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:env-entry"/>
            <xs:field xpath="jakartaee:env-entry-name"/>
          </xs:unique>
          -->
        </xs:element>
        <xs:element name="entity"
                     type="jakartaee:entity-beanType">
          <!--
          <xs:unique name="entity-ejb-local-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The ejb-ref-name element contains the name of
                an EJB reference. The EJB reference is an entry in
                the component's environment and is relative to the
                java:comp/env context.  The name must be unique within
                the component.

                It is recommended that name be prefixed with "ejb/".

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:ejb-local-ref"/>
            <xs:field xpath="jakartaee:ejb-ref-name"/>
          </xs:unique>
          <xs:unique name="entity-ejb-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The ejb-ref-name element contains the name of an EJB
                reference. The EJB reference is an entry in the
                component's environment and is relative to the
                java:comp/env context. The name must be unique
                within the component.

                It is recommended that name is prefixed with "ejb/".

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:ejb-ref"/>
            <xs:field xpath="jakartaee:ejb-ref-name"/>
          </xs:unique>
          <xs:unique name="entity-resource-env-ref-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The resource-env-ref-name element specifies the name
                of a resource environment reference; its value is
                the environment entry name used in the component
                code. The name is a JNDI name relative to the
                java:comp/env context and must be unique within an
                component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:resource-env-ref"/>
            <xs:field xpath="jakartaee:resource-env-ref-name"/>
          </xs:unique>
          <xs:unique name="entity-message-destination-ref-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The message-destination-ref-name element specifies the name
                of a message destination reference; its value is
                the message destination reference name used in the component
                code. The name is a JNDI name relative to the
                java:comp/env context and must be unique within an
                component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:message-destination-ref"/>
            <xs:field xpath="jakartaee:message-destination-ref-name"/>
          </xs:unique>
          <xs:unique name="entity-res-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The res-ref-name element specifies the name of a
                resource manager connection factory reference.  The name
                is a JNDI name relative to the java:comp/env context.
                The name must be unique within an component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:resource-ref"/>
            <xs:field xpath="jakartaee:res-ref-name"/>
          </xs:unique>
          <xs:unique name="entity-env-entry-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The env-entry-name element contains the name of a
                component's environment entry.  The name is a JNDI
                name relative to the java:comp/env context.  The
                name must be unique within an component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:env-entry"/>
            <xs:field xpath="jakartaee:env-entry-name"/>
          </xs:unique>
          -->
        </xs:element>
        <xs:element name="message-driven"
                     type="jakartaee:message-driven-beanType">
          <!--
          <xs:unique name="messaged-ejb-local-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The ejb-ref-name element contains the name of
                an EJB reference. The EJB reference is an entry in
                the component's environment and is relative to the
                java:comp/env context.  The name must be unique within
                the component.

                It is recommended that name be prefixed with "ejb/".

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:ejb-local-ref"/>
            <xs:field xpath="jakartaee:ejb-ref-name"/>
          </xs:unique>
          <xs:unique name="messaged-ejb-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The ejb-ref-name element contains the name of an EJB
                reference. The EJB reference is an entry in the
                component's environment and is relative to the
                java:comp/env context. The name must be unique
                within the component.

                It is recommended that name is prefixed with "ejb/".

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:ejb-ref"/>
            <xs:field xpath="jakartaee:ejb-ref-name"/>
          </xs:unique>
          <xs:unique name="messaged-resource-env-ref-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The resource-env-ref-name element specifies the name
                of a resource environment reference; its value is
                the environment entry name used in the component
                code. The name is a JNDI name relative to the
                java:comp/env context and must be unique within an
                component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:resource-env-ref"/>
            <xs:field xpath="jakartaee:resource-env-ref-name"/>
          </xs:unique>
          <xs:unique name="messaged-message-destination-ref-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The message-destination-ref-name element specifies the name
                of a message destination reference; its value is
                the message destination reference name used in the component
                code. The name is a JNDI name relative to the
                java:comp/env context and must be unique within an
                component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:message-destination-ref"/>
            <xs:field xpath="jakartaee:message-destination-ref-name"/>
          </xs:unique>
          <xs:unique name="messaged-res-ref-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The res-ref-name element specifies the name of a
                resource manager connection factory reference.  The name
                is a JNDI name relative to the java:comp/env context.
                The name must be unique within an component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:resource-ref"/>
            <xs:field xpath="jakartaee:res-ref-name"/>
          </xs:unique>
          <xs:unique name="messaged-env-entry-name-uniqueness">
            <xs:annotation>
              <xs:documentation>

                The env-entry-name element contains the name of a
                component's environment entry.  The name is a JNDI
                name relative to the java:comp/env context.  The
                name must be unique within an component.

              </xs:documentation>
            </xs:annotation>
            <xs:selector xpath="jakartaee:env-entry"/>
            <xs:field xpath="jakartaee:env-entry-name"/>
          </xs:unique>
          -->
        </xs:element>
      </xs:choice>
      <xs:attribute name="id"
                     type="xs:ID"/>
   </xs:complexType>
</xs:schema>
