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

<!--
  ~ /*
  ~  * JBoss, Home of Professional Open Source.
  ~  * Copyright 2013, 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 xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:jboss:domain:ee:2.0"
            xmlns="urn:jboss:domain:ee:2.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="2.0">

    <!-- The EE subsystem root element -->
    <xs:element name="subsystem" type="subsystem"/>

    <xs:complexType name="subsystem">
        <xs:sequence>
            <xs:element name="global-modules" type="modulesType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="ear-subdeployments-isolated" default="false" type="ear-subdeployments-isolatedType" minOccurs="0" maxOccurs="1"/>
            <xs:element name="spec-descriptor-property-replacement" type="descriptor-property-replacementType" minOccurs="0" maxOccurs="1" />
            <xs:element name="jboss-descriptor-property-replacement" type="descriptor-property-replacementType" minOccurs="0" maxOccurs="1" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="modulesType">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="module" type="moduleType"/>
        </xs:choice>
    </xs:complexType>

    <xs:complexType name="moduleType">
        <xs:attribute name="name" type="xs:string" use="required"/>
        <xs:attribute name="slot" type="xs:string"/>
        <xs:attribute name="annotations" type="xs:boolean" use="optional" default="false"/>
        <xs:attribute name="meta-inf" type="xs:boolean" use="optional" default="false"/>
        <xs:attribute name="services" type="xs:boolean" use="optional" default="true"/>
    </xs:complexType>

    <xs:simpleType name="ear-subdeployments-isolatedType">
        <xs:annotation>
                <xs:documentation>
                    Flag indicating whether each of the subdeployments within a .ear can access classes belonging to
                    another subdeployment within the same .ear. Setting this to false, allows the subdeployments to
                    see classes belonging to other subdeployments within the .ear.
                    For example:
                    myapp.ear
                     |
                     |--- web.war
                     |
                     |--- ejb1.jar
                     |
                     |--- ejb2.jar

                    If the ear-subdeployments-isolated is set to false, then the classes in web.war can access classes
                    belonging to ejb1.jar and ejb2.jar. Similarly, classes from ejb1.jar can access classes from ejb2.jar
                    (and vice-versa).

                    *Note that this flag, has no effect on the isolated classloader of the .war file(s). i.e. irrespective
                    of whether this flag is set to true or false, the .war within a .ear will have a isolated classloader
                    and other subdeployments within that .ear will not be able to access classes from that .war. This is
                    as per spec*
                </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:boolean"/>
    </xs:simpleType>

    <xs:simpleType name="descriptor-property-replacementType">
        <xs:annotation>
            <xs:documentation>
                Flag indicating whether system property replacement will be performed on a descriptor. This defaults to
                true, however it is disabled in the default configurations.

                Security Node: System properties etc are resolved in the security context of the application server
                itself, not the deployment that contains the file. This means that if you are running with a security
                manager and enable this property, a deployment can potentially access system properties or environment
                entries that the security manager would have otherwise prevented.
            </xs:documentation>
        </xs:annotation>

        <xs:restriction base="xs:boolean"/>
    </xs:simpleType>

</xs:schema>
