<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2013 Jaroslaw Palka<jaroslaw.palka@symentis.pl> 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://www.springframework.org/schema/integration/jgroups"
	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/jgroups"
	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="http://www.springframework.org/schema/integration/spring-integration-2.2.xsd" />

	<xsd:annotation>
		<xsd:documentation><![CDATA[
	Defines the configuration elements for Spring Integration's JGroups adapters.
		]]></xsd:documentation>
	</xsd:annotation>

	<xsd:complexType name="xmlProtocolStackConfiguratorType">

		<xsd:annotation>
			<xsd:documentation><![CDATA[
Creates ProtocolStackConfigurator by reading XML file, it loades it using Spring resource abstraction,
so it can either file in local filesystem, in classoath or from remote URL.
			]]></xsd:documentation>
		</xsd:annotation>

		<xsd:attribute name="resource" type="xsd:string" use="required" />
	</xsd:complexType>


	<xsd:element name="cluster">
		<xsd:annotation>
			<xsd:documentation><![CDATA[
Connects to a JGroups cluster, and returns JChannel object.
			]]></xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="xml-configurator" type="xmlProtocolStackConfiguratorType" />
			</xsd:sequence>
			<xsd:attribute name="name" type="xsd:string" use="required" />
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="inbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation><![CDATA[
This inbound channel adapter receives all messages sent to JGroups cluster.
			]]></xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:attributeGroup ref="integration:channelAdapterAttributes" />

			<xsd:attribute name="cluster" type="xsd:string" use="required">
				<xsd:annotation>
					<xsd:appinfo>
						<tool:annotation kind="ref">
							<tool:expected-type type="org.jgroups.JChannel" />
						</tool:annotation>
					</xsd:appinfo>
				</xsd:annotation>
			</xsd:attribute>

			<xsd:attribute name="header-mapper" type="xsd:string"
				use="optional">
				<xsd:annotation>
					<xsd:appinfo>
						<tool:annotation kind="ref">
							<tool:expected-type
								type="org.springframework.integration.jgroups.JGroupsHeaderMapper" />
						</tool:annotation>
					</xsd:appinfo>
				</xsd:annotation>
			</xsd:attribute>

		</xsd:complexType>
	</xsd:element>

	<xsd:element name="outbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation><![CDATA[
This outbound channel adapter sends message to cluster.
At the moment it only supports sending messages to all members.
			]]></xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>

			<xsd:sequence minOccurs="0">
				<xsd:element ref="integration:poller" minOccurs="0" />
			</xsd:sequence>

			<xsd:attributeGroup ref="integration:channelAdapterAttributes" />

			<xsd:attribute name="cluster" type="xsd:string" use="required">
				<xsd:annotation>
					<xsd:appinfo>
						<tool:annotation kind="ref">
							<tool:expected-type type="org.jgroups.JChannel" />
						</tool:annotation>
					</xsd:appinfo>
				</xsd:annotation>
			</xsd:attribute>

			<xsd:attribute name="header-mapper" type="xsd:string"
				use="optional">
				<xsd:annotation>
					<xsd:appinfo>
						<tool:annotation kind="ref">
							<tool:expected-type
								type="org.springframework.integration.jgroups.JGroupsHeaderMapper" />
						</tool:annotation>
					</xsd:appinfo>
				</xsd:annotation>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
</xsd:schema>
