<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You 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.
-->

<!-- @version $Rev$ $Date$ -->

<xs:schema
    xmlns:geronimo="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"
    targetNamespace="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
    xmlns:connector="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"
    xmlns:security="http://geronimo.apache.org/xml/ns/security-2.0"
    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
    attributeFormDefault="unqualified" version="1.0">

    <xs:annotation>
        <xs:documentation>
            This is an XML Schema Definition for Geronimo Java application
            client deployment plan. In case the Java application client
            deployment plan is provided internally in the java archive, it
            should be named META-INF/geronimo-application-client.xml. In case
            the java application client deployment plan is provided externally,
            the deployment descriptor can be named anything and provided to the
            deploy tool. All the Java application client deployment plan must
            specify the top level element as application-client with namespace
            specified as
            xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0".
            The default location for this document is
            http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0
        </xs:documentation>
    </xs:annotation>

    <xs:import namespace="http://geronimo.apache.org/xml/ns/naming-1.2"
        schemaLocation="geronimo-naming-1.2.xsd">
        <xs:annotation>
            <xs:documentation>
                Import partial schema containing common naming elements, the
                imported plan declares elements like ejb-ref, ejb-local-ref,
                service-ref, resource-ref, and resource-env-ref required by this
                plan schema.
            </xs:documentation>
        </xs:annotation>
    </xs:import>
    <xs:import namespace="http://geronimo.apache.org/xml/ns/security-2.0"
        schemaLocation="geronimo-security-2.0.xsd">
        <xs:annotation>
            <xs:documentation>
                Import Geronimo security deployment plans. The imported plan
                includes complex types for defining security and principals.
            </xs:documentation>
        </xs:annotation>
    </xs:import>
    <xs:import namespace="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"
        schemaLocation="geronimo-connector-1.2.xsd">
        <xs:annotation>
            <xs:documentation>
                Import Geronimo resource adapter deployment plans. The imported
                plan includes complex types for defining connectors and resource
                adapters.
            </xs:documentation>
        </xs:annotation>
    </xs:import>
    <xs:import namespace="http://geronimo.apache.org/xml/ns/deployment-1.2"
        schemaLocation="geronimo-module-1.2.xsd">
        <xs:annotation>
            <xs:documentation>
                Import Geronimo Services deployment plans. The imported plan
                includes complex types like moduleType, environmentType,
                dependenciesType, etc. required by this plan schema.
            </xs:documentation>
        </xs:annotation>
    </xs:import>

    <xs:element name="application-client"
        type="geronimo:application-clientType">
        <xs:annotation>
            <xs:documentation>
                The root element for Geronimo Java application client deployment
                plan, this element should always exist in instance documents. It
                mirrors the application-client defined by
                application-client_1_4.xsd. It specifies the references for the
                java application client modules. These references could be
                reference to external gbeans, ejb modules, service modules,
                resources, or security principals.
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:complexType name="application-clientType">
        <xs:sequence>
            <xs:element ref="sys:client-environment">
                <xs:annotation>
                    <xs:documentation>
                        Reference to client-environment element defined in
                        imported "geronimo-module-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="sys:server-environment">
                <xs:annotation>
                    <xs:documentation>
                        Reference to server-environment element defined in
                        imported "geronimo-module-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>

            <xs:element ref="naming:gbean-ref" minOccurs="0"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        Reference to gbean-ref element defined in imported
                        "geronimo-naming-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="naming:ejb-ref" minOccurs="0"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        Reference to ejb-ref element defined in imported
                        "geronimo-naming-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="naming:service-ref" minOccurs="0"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        Reference to service-ref element defined in imported
                        "geronimo-naming-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="naming:resource-ref" minOccurs="0"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        Reference to resource-ref element defined in imported
                        "geronimo-naming-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="naming:resource-env-ref" minOccurs="0"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        Reference to resource-env-ref element defined in
                        imported "geronimo-naming-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="naming:message-destination" minOccurs="0"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        Reference to message-destination element defined in
                        imported "geronimo-naming-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>

            <xs:element ref="security:default-subject" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>
                        Reference to default-subject element defined in
                        imported "geronimo-security-2.0.xsd"
                        This is the subject run under if you are not logged in.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>

            <xs:sequence minOccurs="0">
                <xs:element name="realm-name" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>
                            The realm-name element names the security realm used
                            for JAAS login
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="callback-handler" type="xs:string"
                    minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>
                            The callback-handler element specifies the name of a
                            callback class provided by the application for JAAS
                            authentication. This class must implement the
                            javax.security.auth.callback.CallbackHandler
                            interface and follow its specification, as this
                            class will be used by the application client
                            container to collect authentication information from
                            the user.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>

            <xs:element name="resource" type="geronimo:resourceType"
                minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        The resource element names contains the definition of
                        all the module-scoped connector resources. The connector
                        resource can be both external and internal to the
                        application client.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>

            <xs:element ref="sys:service" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        Reference to service element defined in imported
                        "geronimo-module-1.2.xsd"
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="resourceType">
        <xs:sequence>
            <xs:choice>
                <xs:element name="external-rar" type="sys:patternType">
                    <xs:annotation>
                        <xs:documentation>
                            The external-rar is a Module ID of the resource
                            adapter in the Geronimo repository.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="internal-rar" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>
                            The internal-rar is a Module ID of the resource
                            adapter in the client module.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:choice>
            <xs:element ref="connector:connector">
                <xs:annotation>
                    <xs:documentation>
                        This element contains the contents of the Resource Group
                        deployment plan. The content is no different that the
                        content of the deployment plan would have been for the
                        server-wide or application-scoped resource group.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

</xs:schema>
