<!-- ~ JBoss, Home of Professional Open Source. ~ Copyright 2010, 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:infinispan:server:endpoint:6.0" 
    xmlns:tns="urn:infinispan:server:endpoint:6.0" 
    elementFormDefault="qualified"
    attributeFormDefault="unqualified" version="6.0">

   <xs:element name="subsystem" type="tns:subsystemType" />

   <xs:complexType name="subsystemType">
      <xs:choice minOccurs="1" maxOccurs="unbounded">
         <xs:element name="hotrod-connector" type="tns:hotrod-connector" />
         <xs:element name="memcached-connector" type="tns:memcached-connector" />
         <xs:element name="rest-connector" type="tns:rest-connector" />
         <xs:element name="websocket-connector" type="tns:websocket-connector" />
      </xs:choice>
   </xs:complexType>

   <xs:complexType name="protocol-connector" abstract="true">
      <xs:attribute name="socket-binding" type="xs:string" use="required">
         <xs:annotation>
            <xs:documentation>The socket on which this connector will bind itself</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="cache-container" type="xs:string" use="required">
         <xs:annotation>
            <xs:documentation>The name of the cache container which will be exposed by this connector</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="name" type="xs:string" use="optional">
         <xs:annotation>
            <xs:documentation>The logical name to give to this connector. This attribute is required when there are more connectors of the same type defined.</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="worker-threads" type="xs:int" use="optional">
         <xs:annotation>
            <xs:documentation>Sets the number of worker threads. Defaults to 160</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="idle-timeout" type="xs:int" use="optional">
         <xs:annotation>
            <xs:documentation>Specifies the maximum time in seconds that connections from clients will be kept open without activity. Defaults to 0 (no timeout) </xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="tcp-nodelay" type="xs:boolean" use="optional">
         <xs:annotation>
            <xs:documentation>Affects TCP NODELAY on the TCP stack. Defaults to enabled</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="send-buffer-size" type="xs:int" use="optional">
         <xs:annotation>
            <xs:documentation>Sets the size of the send buffer.</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="receive-buffer-size" type="xs:int" use="optional">
         <xs:annotation>
            <xs:documentation>Sets the size of the receive buffer.</xs:documentation>
         </xs:annotation>
      </xs:attribute>
   </xs:complexType>

   <xs:complexType name="hotrod-connector">
      <xs:complexContent>
         <xs:extension base="tns:protocol-connector">
            <xs:all>
                <xs:element name="topology-state-transfer" type="tns:topology-state-transfer" minOccurs="0" maxOccurs="1"/>
                <xs:element name="security" type="tns:security" minOccurs="0" maxOccurs="1"/>
            </xs:all>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <xs:complexType name="memcached-connector">
      <xs:complexContent>
         <xs:extension base="tns:protocol-connector">
            <xs:attribute name="cache" type="xs:string" use="optional">
               <xs:annotation>
                  <xs:documentation>The name of the cache to use for the Memcached connector. Defaults to memcachedCache</xs:documentation>
               </xs:annotation>
            </xs:attribute>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <xs:complexType name="rest-connector">
      <xs:attribute name="cache-container" type="xs:string" use="required">
         <xs:annotation>
            <xs:documentation>The name of the cache container which will be exposed by this connector</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="virtual-server" type="xs:string" use="optional">
         <xs:annotation>
            <xs:documentation>The name of the virtual server on which to register the REST connector. Defaults to 'default-host'</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="context-path" type="xs:string" use="optional">
         <xs:annotation>
            <xs:documentation>The context path on which to register the REST connector. Defaults to '' (the root context)</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="security-domain" type="xs:string" use="optional">
         <xs:annotation>
            <xs:documentation>The security domain to use for authentication/authorization purposes. Defaults to none (no authentication)</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="auth-method" type="xs:string" use="optional">
         <xs:annotation>
            <xs:documentation>The authentication method to require. Can be BASIC, DIGEST, CLIENT_CERT, SPNEGO. Defaults to BASIC</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="security-mode" type="tns:security-mode" use="optional">
         <xs:annotation>
            <xs:documentation>Determines whether authentication is required only for writing (WRITE) or for both reads and writes (READ_WRITE). Defaults to READ_WRITE</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="extended-headers" type="tns:extended-headers" use="optional">
         <xs:annotation>
            <xs:documentation>Whether to enable extended headers. Can be NEVER or ON_DEMAND. Defaults to ON_DEMAND</xs:documentation>
         </xs:annotation>
      </xs:attribute>
   </xs:complexType>

   <xs:complexType name="websocket-connector">
      <xs:complexContent>
         <xs:extension base="tns:protocol-connector" />
      </xs:complexContent>
   </xs:complexType>

   <xs:complexType name="topology-state-transfer">
      <xs:attribute name="cache-suffix" type="xs:string" use="optional">
         <xs:annotation>
            <xs:documentation>Whether to enable extended headers. Can be NEVER or ON_DEMAND. Defaults to ON_DEMAND</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="lock-timeout" type="xs:int" use="optional">
         <xs:annotation>
            <xs:documentation>Configures the lock acquisition timeout for the topology cache. Defaults to 10 seconds</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="replication-timeout" type="xs:int" use="optional">
         <xs:annotation>
            <xs:documentation>Configures the replication timeout for the topology cache. Defaults to 10 seconds</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="update-timeout" type="xs:int" use="optional">
         <xs:annotation>
            <xs:documentation>This setting has been deprecated and will be ignored.</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="external-host" type="xs:string" use="optional">
         <xs:annotation>
            <xs:documentation>Sets the external address of this node, i.e. the address which clients will connect to. Defaults to the server's socket-binding address</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="external-port" type="xs:int" use="optional">
         <xs:annotation>
            <xs:documentation>Sets the external port of this node, i.e. the port which clients will connect to. Defaults to the server's socket-binding port</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="lazy-retrieval" type="xs:boolean" use="optional">
         <xs:annotation>
            <xs:documentation>Configures whether to enable state transfer for the topology cache. If disabled, a ClusterCacheLoader will be used to lazily retrieve topology information from the other nodes. Defaults to true.</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="await-initial-transfer" type="xs:boolean" use="optional" default="true">
         <xs:annotation>
            <xs:documentation>Configures whether to initial state retrieval should happen immediately at startup. Only applies when lazy-retrieval is false. Defaults to true.</xs:documentation>
         </xs:annotation>
      </xs:attribute>
   </xs:complexType>
   
   <xs:complexType name="security">
      <xs:attribute name="require-ssl-client-auth" type="xs:boolean" use="optional">
         <xs:annotation>
            <xs:documentation>Whether to require client certificate authentication. Defaults to false.</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="security-realm" type="xs:string" use="optional">
         <xs:annotation>
            <xs:documentation>The name of the security realm to use for obtaining the SSL keystore</xs:documentation>
         </xs:annotation>
      </xs:attribute>
      <xs:attribute name="ssl" type="xs:boolean" use="optional">
         <xs:annotation>
            <xs:documentation>Whether to enable SSL. Defaults to false</xs:documentation>
         </xs:annotation>
      </xs:attribute>
   </xs:complexType>

   <xs:simpleType name="security-mode">
      <xs:restriction base="xs:token">
         <xs:enumeration value="WRITE">
            <xs:annotation>
               <xs:documentation>Specifies that authentication against the specified security domain should apply only to write methods (PUT, POST, DELETE)</xs:documentation>
            </xs:annotation>
         </xs:enumeration>
         <xs:enumeration value="READ_WRITE">
            <xs:annotation>
               <xs:documentation>Specifies that authentication against the specified security domain should apply to all methods (PUT, POST, DELETE, GET, HEAD)</xs:documentation>
            </xs:annotation>
         </xs:enumeration>
      </xs:restriction>
   </xs:simpleType>
   
   <xs:simpleType name="extended-headers">
      <xs:restriction base="xs:token">
         <xs:enumeration value="NEVER">
            <xs:annotation>
               <xs:documentation>Never return extended headers</xs:documentation>
            </xs:annotation>
         </xs:enumeration>
         <xs:enumeration value="ON_DEMAND">
            <xs:annotation>
               <xs:documentation>Return extended headers on demand (i.e. when the 'extendend' query parameter is present on the request)</xs:documentation>
            </xs:annotation>
         </xs:enumeration>
      </xs:restriction>
   </xs:simpleType>
</xs:schema>
