<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
    /*
    * $Revision$
    *
    * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
    *
    * 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="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.3.0"
            xmlns:ext100="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
            xmlns:ext110="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0"
            xmlns:ext120="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.2.0"
            xmlns:ext130="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.3.0"
            xmlns:ext140="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.4.0"
            xmlns:ext150="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.5.0"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            targetNamespace="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.3.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0.0">

    <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
    <xsd:import namespace="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" />
    <xsd:import namespace="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0" />
    <xsd:import namespace="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.2.0" />
    <xsd:import namespace="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.3.0" />
    <xsd:import namespace="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.4.0" />
    <xsd:import namespace="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.5.0" />

    <!-- property placeholder -->

    <xsd:element name="property-placeholder" type="TpropertyPlaceholder"/>

    <xsd:complexType name="TpropertyPlaceholder">
        <xsd:complexContent>
            <xsd:extension base="bp:Tcomponent">
                <xsd:sequence>
                    <!-- nested properties declaration -->
                    <xsd:element name="default-properties" type="TdefaultProperties" minOccurs="0" maxOccurs="1"/>
                    <xsd:choice minOccurs="0" maxOccurs="unbounded">
                        <xsd:element ref="ext100:location" />
                        <xsd:element ref="ext110:location" />
                        <xsd:element ref="ext120:location" />
                        <xsd:element ref="ext130:location" />
                        <xsd:element ref="ext140:location" />
                        <xsd:element ref="ext150:location" />
                    </xsd:choice>
                </xsd:sequence>

                <!-- #### What should be the type for a persistent id?  I think we need to define one like class and method -->
                <xsd:attribute name="persistent-id" type="xsd:string" use="required"/>
                <xsd:attribute name="placeholder-prefix" type="xsd:string" use="optional" default="${"/>
                <xsd:attribute name="placeholder-suffix" type="xsd:string" use="optional" default="}"/>
                <xsd:attribute name="defaults-ref" type="bp:Tidref" use="optional"/>
                <xsd:attribute name="update-strategy" type="TplaceholderUpdateStrategyType" use="optional" default="none"/>
                <xsd:attributeGroup ref="extAttributes" />
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:simpleType name="TplaceholderUpdateStrategyType">
        <xsd:restriction base="xsd:NMTOKEN">
            <xsd:enumeration value="none"/>
            <xsd:enumeration value="reload"/>
        </xsd:restriction>
    </xsd:simpleType>

    <!-- #### is this the correct type here?  This is defining placeholder properties,
         so should this be a restricted set of value types or should this be expanded to
         all of the elements you can inject into a bean property? -->
    <xsd:complexType name="TdefaultProperties">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="property" type="bp:Tproperty"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:attributeGroup name="extAttributes">
        <xsd:attribute ref="ext100:ignore-missing-locations" use="optional" />
        <xsd:attribute ref="ext110:ignore-missing-locations" use="optional" />
        <xsd:attribute ref="ext120:ignore-missing-locations" use="optional" />
        <xsd:attribute ref="ext130:ignore-missing-locations" use="optional" />
        <xsd:attribute ref="ext140:ignore-missing-locations" use="optional" />
        <xsd:attribute ref="ext150:ignore-missing-locations" use="optional" />
        <xsd:attribute ref="ext100:system-properties" use="optional" />
        <xsd:attribute ref="ext110:system-properties" use="optional" />
        <xsd:attribute ref="ext120:system-properties" use="optional" />
        <xsd:attribute ref="ext130:system-properties" use="optional" />
        <xsd:attribute ref="ext140:system-properties" use="optional" />
        <xsd:attribute ref="ext150:system-properties" use="optional" />
    </xsd:attributeGroup>

    <!--  managed-properties  -->

    <xsd:element name="managed-properties" type="TmanagedProperties"/>

    <xsd:complexType name="TmanagedProperties">
        <xsd:attribute name="persistent-id" type="xsd:string" use="required"/>
        <xsd:attribute name="update-strategy" type="TupdateStrategyType" use="optional"/>
        <xsd:attribute name="update-method" type="xsd:string" use="optional"/>
    </xsd:complexType>

    <xsd:simpleType name="TupdateStrategyType">
        <xsd:restriction base="xsd:NMTOKEN">
            <xsd:enumeration value="none"/>
            <xsd:enumeration value="component-managed"/>
            <xsd:enumeration value="container-managed"/>
        </xsd:restriction>
    </xsd:simpleType>

    <!--  managed-service-factory -->

    <xsd:element name="managed-service-factory" type="TmanagedServiceFactory"/>

    <xsd:complexType name="TmanagedServiceFactory">
        <xsd:complexContent>
            <xsd:extension base="bp:Tcomponent">
                <xsd:sequence>
                    <xsd:group ref="bp:GbaseServiceElements"/>
                    <xsd:element name="managed-component" type="TmanagedComponent" minOccurs="1" maxOccurs="1"/>
                </xsd:sequence>
                <xsd:attribute name="interface" type="bp:Tclass" use="optional" />
                <xsd:attribute name="ref" type="bp:Tidref" use="optional" />
                <xsd:attribute name="auto-export" type="bp:TautoExportModes" default="disabled" />
                <xsd:attribute name="ranking" type="xsd:int" default="0"/>
                <xsd:attribute name="factory-pid" type="xsd:string" use="required"/>
                <xsd:anyAttribute namespace="##other" processContents="strict"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="TmanagedComponent">
        <xsd:group ref="bp:GbeanElements"/>
        <xsd:attribute name="class" type="bp:Tclass"/>
        <xsd:attribute name="init-method" type="bp:Tmethod"/>
        <xsd:attribute name="destroy-method" type="bp:Tmethod"/>
        <xsd:attribute name="factory-method" type="bp:Tmethod"/>
        <xsd:attribute name="factory-ref" type="bp:Tidref"/>
        <xsd:anyAttribute namespace="##other" processContents="strict"/>
    </xsd:complexType>


    <!-- cm-properties -->

    <xsd:element name="cm-properties" type="TcmProperties"/>

    <xsd:complexType name="TcmProperties">
        <xsd:complexContent>
            <xsd:extension base="bp:Tcomponent">
                <xsd:attribute name="persistent-id" type="xsd:string" use="required"/>
                <xsd:attribute name="update" type="xsd:boolean" use="optional" default="false"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

</xsd:schema>
