<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.mulesource.org/schema/mule/jms/2.0"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:mule="http://www.mulesource.org/schema/mule/core/2.0"
            targetNamespace="http://www.mulesource.org/schema/mule/jms/2.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified">

    <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
    <xsd:import namespace="http://www.mulesource.org/schema/mule/core/2.0" 
                schemaLocation="http://www.mulesource.org/schema/mule/core/2.0/mule.xsd" />

    <!-- Generic JMS Connector -->    
    <xsd:element name="connector" type="genericConnectorType" substitutionGroup="mule:abstract-connector"/>
    <xsd:complexType name="genericConnectorType">
        <xsd:complexContent>
            <xsd:extension base="mule:connectorType">
                <!-- The ConnectionFactory is required for non-vendor JMS configs -->
                <xsd:attribute name="connectionFactory-ref" type="xsd:NMTOKEN" use="required"/>
                <xsd:attributeGroup ref="jmsConnectorAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <!-- Custom JMS Connector -->    
    <xsd:element name="custom-connector" substitutionGroup="mule:abstract-connector">
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="mule:customConnectorType">
                    <xsd:attributeGroup ref="jmsConnectorAttributes"/>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>

    <xsd:attributeGroup name="jmsConnectorAttributes">
        <xsd:attribute name="redeliveryHandlerFactory-ref" type="xsd:NMTOKEN"/>
        <xsd:attribute name="acknowledgementMode" default="AUTO_ACKNOWLEDGE">
            <xsd:simpleType>
                <xsd:restriction base="xsd:NMTOKEN">
                    <xsd:enumeration value="AUTO_ACKNOWLEDGE"/>
                    <xsd:enumeration value="CLIENT_ACKNOWLEDGE"/>
                    <xsd:enumeration value="DUPS_OK_ACKNOWLEDGE"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="clientId" type="xsd:string"/>
        <xsd:attribute name="durable" type="mule:substitutableBoolean"/>
        <xsd:attribute name="noLocal" type="mule:substitutableBoolean"/>
        <xsd:attribute name="persistentDelivery" type="mule:substitutableBoolean"/>
        <xsd:attribute name="honorQosHeaders" type="mule:substitutableBoolean"/>
        <xsd:attribute name="maxRedelivery" type="mule:substitutableInt"/>
        <xsd:attribute name="cacheJmsSessions" type="mule:substitutableBoolean"/>
        <xsd:attribute name="recoverJmsConnections" type="mule:substitutableBoolean"/>
        <xsd:attribute name="eagerConsumer" type="mule:substitutableBoolean"/>
        <!-- Defaults to org.mule.transport.jms.JmsConstants.JMS_SPECIFICATION_102B  -->
        <xsd:attribute name="specification" default="1.0.2b">
            <xsd:simpleType>
                <xsd:restriction base="xsd:NMTOKEN">
                    <xsd:enumeration value="1.0.2b"/>
                    <xsd:enumeration value="1.1"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="username" type="xsd:string"/>
        <xsd:attribute name="password" type="xsd:string"/>
    </xsd:attributeGroup>


    <!-- Vendor-specific JMS Connectors -->
         
    <xsd:complexType name="vendorJmsConnectorType">
        <xsd:complexContent>
            <xsd:extension base="mule:connectorType">
                <!-- Optional, a default ConnectionFactory is provided for vendor JMS configs -->
                <xsd:attribute name="connectionFactory-ref" type="xsd:NMTOKEN" use="optional"/>
                <xsd:attributeGroup ref="jmsConnectorAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="activemq-connector" type="activeMqConnectorType" substitutionGroup="mule:abstract-connector"/>
    <xsd:element name="activemq-xa-connector" type="activeMqConnectorType" substitutionGroup="mule:abstract-connector"/>
    <xsd:complexType name="activeMqConnectorType">
        <xsd:complexContent>
            <xsd:extension base="vendorJmsConnectorType">
                <xsd:attribute name="brokerURL" type="xsd:string"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    
    <xsd:element name="weblogic-connector" type="vendorJmsConnectorType" substitutionGroup="mule:abstract-connector"/>
    <xsd:element name="websphere-connector" type="vendorJmsConnectorType" substitutionGroup="mule:abstract-connector"/>
 
    <xsd:element name="transaction" type="mule:baseTransactionType" substitutionGroup="mule:abstract-transaction"/>
    <xsd:element name="client-ack-transaction" type="mule:baseTransactionType" substitutionGroup="mule:abstract-transaction"/>
    <xsd:element name="xa-transaction" type="mule:baseTransactionType" substitutionGroup="mule:abstract-transaction"/>

    <xsd:element name="jmsmessage-to-object-transformer" type="mule:abstractTransformerType" substitutionGroup="mule:abstract-transformer"/>
    <xsd:element name="object-to-jmsmessage-transformer" type="mule:abstractTransformerType" substitutionGroup="mule:abstract-transformer"/>
    
    <xsd:element name="inbound-endpoint" type="inboundEndpointType" substitutionGroup="mule:abstract-inbound-endpoint"/>
    <xsd:complexType name="inboundEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:abstractInboundEndpointType">
                <xsd:group ref="defaultEndpointElements"/>
                <xsd:attributeGroup ref="mule:defaultEndpointAttributes"/>
                <xsd:attributeGroup ref="addressAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="outbound-endpoint" type="outboundEndpointType" substitutionGroup="mule:abstract-outbound-endpoint"/>
    <xsd:complexType name="outboundEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:abstractOutboundEndpointType">
                <xsd:group ref="defaultEndpointElements"/>
                <xsd:attributeGroup ref="mule:defaultEndpointAttributes"/>
                <xsd:attributeGroup ref="addressAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="endpoint" type="globalEndpointType" substitutionGroup="mule:abstract-global-endpoint"/>
    <xsd:complexType name="globalEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:abstractGlobalEndpointType">
                <xsd:group ref="defaultEndpointElements"/>
                <xsd:attributeGroup ref="mule:defaultEndpointAttributes"/>
                <xsd:attributeGroup ref="addressAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:attributeGroup name="addressAttributes">
        <xsd:attribute name="queue" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The queue name.
                    This cannot be used with the topic attribute (the two are exclusive).
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="topic" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The topic name.  The "topic:" prefix will be added automatically.
                    This cannot be used with the queue attribute (the two are exclusive).
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:attributeGroup>

    <!-- these include option/repeats - should be embedded once -->
    <!-- this is a modified version of what is in mule.xsd, allowing either a selector or a
         normal filter to be set -->
    <xsd:group name="defaultEndpointElements">
        <xsd:sequence>
            <xsd:sequence minOccurs="0" maxOccurs="unbounded">
                <xsd:group ref="mule:endpointTransformers"/>
                <xsd:element ref="mule:abstract-transaction" minOccurs="0"/>
                <xsd:choice>
                    <xsd:element ref="mule:abstract-filter" minOccurs="0"/>
                    <xsd:element name="selector" type="jmsSelectorFilter" minOccurs="0"/>
                </xsd:choice>
                <xsd:element ref="mule:abstract-security-filter" minOccurs="0"/>
                <xsd:group ref="mule:propertiesGroup"/>
            </xsd:sequence>
        </xsd:sequence>
    </xsd:group>

    <xsd:complexType name="jmsSelectorFilter">
        <xsd:annotation>
            <xsd:documentation>
                This sets a selector on the underlying JMS transport.
                It is not a standard Mule filter - it cannot be combined with other filters.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:attribute name="expression" type="xsd:string"/>
    </xsd:complexType>

    <xsd:element name="property-filter" substitutionGroup="mule:abstract-filter">
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="mule:abstractFilterType">
                    <xsd:attribute name="propertyName" type="xsd:string"/>
                    <xsd:attribute name="propertyClass" type="xsd:string"/>
                    <xsd:attribute name="expression" type="xsd:string"/>
                    <xsd:attribute name="pattern" type="xsd:string"/>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>

</xsd:schema>
