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

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2011, 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:pojo:7.0"
            xmlns="urn:jboss:pojo:7.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0">

    <xs:complexType name="deployment">
        <xs:sequence>
            <xs:element name="bean" type="bean" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="bean">
        <xs:sequence>
            <xs:element name="alias" type="alias" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="classloader" type="classloader" minOccurs="0" maxOccurs="1"/>
            <xs:element name="constructor" type="constructor" minOccurs="0" maxOccurs="1"/>
            <xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="create" type="lifecycle" minOccurs="0" maxOccurs="1"/>
            <xs:element name="start" type="lifecycle" minOccurs="0" maxOccurs="1"/>
            <xs:element name="stop" type="lifecycle" minOccurs="0" maxOccurs="1"/>
            <xs:element name="destroy" type="lifecycle" minOccurs="0" maxOccurs="1"/>
            <xs:element name="install" type="install" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="uninstall" type="install" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="incallback" type="callback" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="uncallback" type="callback" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="depends" type="depends" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required"/>
        <xs:attribute name="class" type="xs:string" use="optional"/>
        <xs:attribute name="mode" type="mode" use="optional"/>
    </xs:complexType>

    <xs:complexType name="alias" mixed="true" />

    <xs:complexType name="classloader">
        <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>

    <xs:complexType name="constructor">
        <xs:sequence>
            <xs:element name="factory" type="parameter" minOccurs="0" maxOccurs="1"/>
            <xs:element name="parameter" type="parameter" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="factory-class" type="xs:string" use="optional"/>
        <xs:attribute name="factory-method" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:simpleType name="mode">
        <xs:restriction base="xs:token">
            <xs:enumeration value="active"/>
            <xs:enumeration value="passive"/>
            <xs:enumeration value="on demand"/>
            <xs:enumeration value="never"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="property">
        <xs:choice minOccurs="0" maxOccurs="1">
            <xs:element name="value" type="value"/>
            <xs:element name="inject" type="inject"/>
            <xs:element name="value-factory" type="value-factory"/>
            <xs:element name="list" type="collection"/>
            <xs:element name="set" type="collection"/>
            <xs:element name="map" type="map"/>
        </xs:choice>
        <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>

    <xs:complexType name="depends">
        <xs:attribute name="state" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:complexType name="inject">
        <xs:attribute name="bean" type="xs:string" use="optional"/>
        <xs:attribute name="service" type="xs:string" use="optional"/>
        <xs:attribute name="property" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:complexType name="value-factory">
        <xs:sequence>
            <xs:element name="parameter" type="parameter" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="bean" type="xs:string" use="required"/>
        <xs:attribute name="method" type="xs:string" use="required"/>
    </xs:complexType>

    <xs:complexType name="collection">
        <xs:sequence>
            <xs:element name="value" type="value"/>
            <xs:element name="inject" type="inject"/>
            <xs:element name="value-factory" type="value-factory"/>
            <xs:element name="list" type="collection"/>
            <xs:element name="set" type="collection"/>
            <xs:element name="map" type="map"/>
        </xs:sequence>
        <xs:attribute name="class" type="xs:string" use="optional"/>
        <xs:attribute name="elementClass" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:complexType name="map">
        <xs:sequence>
            <xs:element name="entry" type="entry"/>
        </xs:sequence>
        <xs:attribute name="class" type="xs:string" use="optional"/>
        <xs:attribute name="keyClass" type="xs:string" use="optional"/>
        <xs:attribute name="valueClass" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:complexType name="entry">
        <xs:sequence>
            <xs:element name="key" type="value-value"/>
            <xs:element name="value" type="value-value"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="value-value" mixed="true">
        <xs:sequence>
            <xs:element name="value" type="value"/>
            <xs:element name="inject" type="inject"/>
            <xs:element name="value-factory" type="value-factory"/>
            <xs:element name="list" type="collection"/>
            <xs:element name="set" type="collection"/>
            <xs:element name="map" type="map"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="lifecycle">
        <xs:sequence>
            <xs:element name="parameter" type="parameter" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="method" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:complexType name="install">
        <xs:sequence>
            <xs:element name="parameter" type="parameter" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="bean" type="xs:string" use="optional"/>
        <xs:attribute name="method" type="xs:string" use="required"/>
        <xs:attribute name="whenRequired" type="xs:string" use="optional"/>
        <xs:attribute name="state" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:complexType name="callback">
        <xs:attribute name="method" type="xs:string" use="required"/>
        <xs:attribute name="whenRequired" type="xs:string" use="optional"/>
        <xs:attribute name="state" type="xs:string" use="optional"/>
        <xs:attribute name="signature" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:complexType name="value" mixed="true">
        <xs:attribute name="replace" type="xs:boolean" use="optional"/>
        <xs:attribute name="trim" type="xs:boolean" use="optional"/>
    </xs:complexType>

    <xs:complexType name="parameter">
        <xs:attribute name="class" type="xs:string" use="optional"/>
    </xs:complexType>

    <!-- Root elements -->

    <xs:element name="deployment" type="deployment"/>
</xs:schema>