<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.springframework.org/schema/integration/smpp"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:beans="http://www.springframework.org/schema/beans"
            xmlns:tool="http://www.springframework.org/schema/tool"
            xmlns:integration="http://www.springframework.org/schema/integration"
            targetNamespace="http://www.springframework.org/schema/integration/smpp"
            elementFormDefault="qualified" attributeFormDefault="unqualified">

	<xsd:import namespace="http://www.springframework.org/schema/beans" />
	<xsd:import namespace="http://www.springframework.org/schema/tool" />
	<xsd:import namespace="http://www.springframework.org/schema/integration"
		schemaLocation="https://www.springframework.org/schema/integration/spring-integration.xsd" />

	<xsd:annotation>
		<xsd:documentation><![CDATA[
			Defines the configuration elements for the Spring Integration
			Smpp Adapter.
		]]></xsd:documentation>
	</xsd:annotation>

	<xsd:element name="inbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
				The definition for the Spring Integration Smpp
				Inbound Channel Adapter.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
            <xsd:choice minOccurs="0" maxOccurs="1">
                <xsd:element minOccurs="0" maxOccurs="1" ref="session"/>
            </xsd:choice>
			<xsd:attributeGroup ref="coreSmppComponentAttributes"/>
            <xsd:attribute name="auto-startup" default="true" use="optional">
                <xsd:annotation>
                    <xsd:documentation>
                        Flag to indicate that the component should start automatically
                        on startup (default true).
                    </xsd:documentation>
                </xsd:annotation>
                <xsd:simpleType>
                    <xsd:union memberTypes="xsd:boolean xsd:string" />
                </xsd:simpleType>
            </xsd:attribute>
			<xsd:attribute name="channel" type="xsd:string">
				<xsd:annotation>
                    <xsd:documentation>
                        Channel which the sms will be put in, whey they come from the SMSC.
                    </xsd:documentation>
					<xsd:appinfo>
						<tool:annotation kind="ref">
							<tool:expected-type type="org.springframework.integration.core.MessageChannel" />
						</tool:annotation>
					</xsd:appinfo>
				</xsd:annotation>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>

    <xsd:element name="inbound-gateway">
        <xsd:annotation>
            <xsd:documentation>
                Defines the Spring Integration Smpp Inbound Gateway
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:complexContent>
                <xsd:extension base="smppGatewayType">
                    <xsd:choice minOccurs="0" maxOccurs="1">
                        <xsd:element minOccurs="0" maxOccurs="1" ref="session"/>
                    </xsd:choice>
                    <xsd:attribute name="error-channel" type="xsd:string">
                        <xsd:annotation>
                            <xsd:appinfo>
                                <tool:annotation kind="ref">
                                    <tool:expected-type type="org.springframework.integration.core.MessageChannel" />
                                </tool:annotation>
                            </xsd:appinfo>
                        </xsd:annotation>
                    </xsd:attribute>
                    <xsd:attribute name="request-timeout" type="xsd:string" />
                    <xsd:attribute name="request-mapper" use="optional">
                        <xsd:annotation>
                            <xsd:appinfo>
                                <tool:annotation kind="ref">
                                    <tool:expected-type type="org.springframework.integration.mapping.InboundMessageMapper" />
                                </tool:annotation>
                            </xsd:appinfo>
                        </xsd:annotation>
                    </xsd:attribute>
                    <xsd:attribute name="reply-mapper" use="optional">
                        <xsd:annotation>
                            <xsd:appinfo>
                                <tool:annotation kind="ref">
                                    <tool:expected-type type="org.springframework.integration.mapping.OutboundMessageMapper" />
                                </tool:annotation>
                            </xsd:appinfo>
                        </xsd:annotation>
                    </xsd:attribute>
                </xsd:extension>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="outbound-channel-adapter">
        <xsd:annotation>
            <xsd:documentation>
                Defines an Outbound Channel Adapter.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:choice minOccurs="0" maxOccurs="2">
                <xsd:element minOccurs="0" maxOccurs="1" ref="session"/>
                <xsd:element name="request-handler-advice-chain"
                             type="integration:adviceChainType" minOccurs="0" maxOccurs="1" />
            </xsd:choice>
            <xsd:attributeGroup ref="coreSmppComponentAttributes"/>
            <xsd:attribute name="channel" type="xsd:string">
                <xsd:annotation>
                    <xsd:appinfo>
                        <xsd:documentation>
                            Channel from which messages will be output.
                            When a message is sent to this channel it will
                            cause the query
                            to be executed.
                        </xsd:documentation>
                        <tool:annotation kind="ref">
                            <tool:expected-type type="org.springframework.integration.MessageChannel" />
                        </tool:annotation>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:attribute>
            <xsd:attribute name="source-address" type="xsd:string" use="optional">
                <xsd:annotation>
                    <xsd:documentation>
                        Source address will be used as sender for SMPP
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:attribute>
            <xsd:attribute name="source-ton">
                <xsd:annotation>
                    <xsd:documentation>
                        The default source address Type of Number. Default is UNKNOWN.
                    </xsd:documentation>
                </xsd:annotation>
                <xsd:simpleType>
                    <xsd:union memberTypes="tonEnumeration xsd:string"/>
                </xsd:simpleType>
            </xsd:attribute>
            <xsd:attribute name="time-formatter">
                <xsd:annotation>
                    <xsd:documentation>
                        Reference to jsmpp time formatter
                    </xsd:documentation>
                    <xsd:appinfo>
                        <tool:annotation kind="ref">
                            <tool:expected-type type="org.jsmpp.util.TimeFormatter"/>
                        </tool:annotation>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:attribute>
        </xsd:complexType>
    </xsd:element>

	<xsd:element name="outbound-gateway">
		<xsd:annotation>
			<xsd:documentation>
				Defines the Spring Integration Smpp Outbound Gateway
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="smppGatewayType">
                    <xsd:choice minOccurs="0" maxOccurs="2">
                        <xsd:element minOccurs="0" maxOccurs="1" ref="session"/>
                        <xsd:element name="request-handler-advice-chain"
                                     type="integration:adviceChainType" minOccurs="0" maxOccurs="1" />
                    </xsd:choice>
                    <xsd:attribute name="time-formatter">
                        <xsd:annotation>
                            <xsd:documentation>
                                Reference to jsmpp time formatter
                            </xsd:documentation>
                            <xsd:appinfo>
                                <tool:annotation kind="ref">
                                    <tool:expected-type type="org.jsmpp.util.TimeFormatter"/>
                                </tool:annotation>
                            </xsd:appinfo>
                        </xsd:annotation>
                    </xsd:attribute>
					<xsd:attribute name="order">
						<xsd:annotation>
							<xsd:documentation>
								Specifies the order for invocation when this endpoint is connected as a
								subscriber to a SubscribableChannel.
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

    <xsd:element name="session">
        <xsd:annotation>
            <xsd:documentation>
                Defines reference to smpp session
            </xsd:documentation>
            <xsd:appinfo>
                <tool:annotation>
                    <tool:exports type="org.springframework.integration.smpp.session.ExtendedSmppSession"/>
                </tool:annotation>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexType>
            <xsd:choice minOccurs="0" maxOccurs="1">
                <xsd:element minOccurs="0" maxOccurs="1" ref="beans:bean"/>
            </xsd:choice>
            <xsd:attribute name="id" type="xsd:string" use="optional"/>
            <xsd:attribute name="ref">
                <xsd:annotation>
                    <xsd:documentation>
                        Reference to extended smpp session
                    </xsd:documentation>
                    <xsd:appinfo>
                        <tool:annotation kind="ref">
                            <tool:expected-type type="org.springframework.integration.smpp.session.ExtendedSmppSession"/>
                        </tool:annotation>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:attribute>
        </xsd:complexType>
    </xsd:element>

    <xsd:complexType name="smppSessionType">
        <xsd:annotation>
            <xsd:documentation>
                Defines the Spring Integration Smpp Session
            </xsd:documentation>
            <xsd:appinfo>
                <tool:annotation>
                    <tool:exports type="org.springframework.integration.smpp.session.ExtendedSmppSession"/>
                </tool:annotation>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:attribute name="id" type="xsd:string" use="optional"/>
        <xsd:attribute name="bind-type">
            <xsd:annotation>
                <xsd:documentation>Type of SMPP connection bind.</xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
                <xsd:union memberTypes="typeOfBindEnumeration xsd:string"/>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="enquire-link-timer" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>Set enquire link timer (in milliseconds).</xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="transaction-timer" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>Set transaction timer (in milliseconds).</xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="use-ssl" type="xsd:boolean"/>
        <xsd:attribute name="host" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>Host to connect (default 127.0.0.1)</xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="address-range" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>Address range we are listening to</xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="timeout" type="xsd:long">
            <xsd:annotation>
                <xsd:documentation>Connection timeout (default 60000ms / 1 minute)</xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="port" type="xsd:int">
            <xsd:annotation>
                <xsd:documentation>Port to connect (default 2775)</xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="system-id" type="xsd:string"/>
        <xsd:attribute name="password" type="xsd:string"/>
        <xsd:attribute name="system-type" type="xsd:string"/>
        <xsd:attribute name="addr-ton">
            <xsd:annotation>
                <xsd:documentation>The address Type of Number. Default is UNKNOWN.</xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
                <xsd:union memberTypes="tonEnumeration xsd:string"/>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="addr-npi">
            <xsd:annotation>
                <xsd:documentation>The address Numbering Plan Indicator. Default is UNKNOWN</xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
                <xsd:union memberTypes="npiEnumeration xsd:string"/>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>

	<xsd:simpleType name="tonEnumeration">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="UNKNOWN"/>
            <xsd:enumeration value="INTERNATIONAL"/>
            <xsd:enumeration value="NATIONAL"/>
            <xsd:enumeration value="NETWORK_SPECIFIC"/>
            <xsd:enumeration value="SUBSCRIBER_NUMBER"/>
            <xsd:enumeration value="ALPHANUMERIC"/>
            <xsd:enumeration value="ABBREVIATED"/>
        </xsd:restriction>
	</xsd:simpleType>

    <xsd:simpleType name="npiEnumeration">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="UNKNOWN"/>
            <xsd:enumeration value="ISDN"/>
            <xsd:enumeration value="DATA"/>
            <xsd:enumeration value="TELEX"/>
            <xsd:enumeration value="LAND_MOBILE"/>
            <xsd:enumeration value="NATIONAL"/>
            <xsd:enumeration value="PRIVATE"/>
            <xsd:enumeration value="ERMES"/>
            <xsd:enumeration value="INTERNET"/>
            <xsd:enumeration value="WAP"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="typeOfBindEnumeration">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="BIND_TX">
                <xsd:annotation>
                    <xsd:documentation>
                        Bind as Transmitter (Sending Only)
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="BIND_RX">
                <xsd:annotation>
                    <xsd:documentation>
                        Bind as Receiver (Receive Only)
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="BIND_TRX">
                <xsd:annotation>
                    <xsd:documentation>
                        Bind as Transceiver (Sending and Receive)
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:enumeration>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:attributeGroup name="coreSmppComponentAttributes">
        <xsd:attribute name="id" type="xsd:string" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    Identifies the underlying Spring bean definition, which is an
                    instance of either 'EventDrivenConsumer' or 'PollingConsumer',
                    depending on whether the component's input channel is a
                    'SubscribableChannel' or 'PollableChannel'.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="smpp-session-ref">
            <xsd:annotation>
                <xsd:documentation>
                    Reference to extended smpp session
                </xsd:documentation>
                <xsd:appinfo>
                    <tool:annotation kind="ref">
                        <tool:expected-type type="org.springframework.integration.smpp.session.ExtendedSmppSession"/>
                    </tool:annotation>
                </xsd:appinfo>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:attributeGroup>

	<xsd:complexType name="smppGatewayType">
		<xsd:annotation>
			<xsd:documentation>
				Defines common configuration for gateway adapters.
			</xsd:documentation>
		</xsd:annotation>
        <xsd:attributeGroup ref="coreSmppComponentAttributes"/>
		<xsd:attribute name="reply-channel" type="xsd:string">
			<xsd:annotation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type type="org.springframework.integration.MessageChannel" />
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
        <xsd:attribute name="reply-timeout" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation><![CDATA[
								Allows you to specify how long this gateway will wait for
								the reply message to be sent successfully before throwing
								an exception. Keep in mind that when sending to a
								DirectChannel, the invocation will occur in the sender's thread
								so the failing of the send operation may be caused by other
								components further downstream. By default the Gateway will
								wait indefinitely. The value is specified in milliseconds.
								]]>
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="request-channel" type="xsd:string" use="required">
            <xsd:annotation>
                <xsd:documentation>
                    The receiving Message Channel of this endpoint.
                </xsd:documentation>
                <xsd:appinfo>
                    <tool:annotation kind="ref">
                        <tool:expected-type type="org.springframework.integration.core.MessageChannel" />
                    </tool:annotation>
                </xsd:appinfo>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="source-address" type="xsd:string" use="optional">
            <xsd:annotation>
                <xsd:documentation>
                    Source address will be used as sender for SMPP
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="source-ton">
            <xsd:annotation>
                <xsd:documentation>
                    The default source address Type of Number. Default is UNKNOWN.
                </xsd:documentation>
            </xsd:annotation>
            <xsd:simpleType>
                <xsd:union memberTypes="tonEnumeration xsd:string"/>
            </xsd:simpleType>
        </xsd:attribute>
	</xsd:complexType>

</xsd:schema>
