<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">

  <!-- ===================================================================== -->
  <!-- Set up support for queries and index on session expiry time.          -->
  <!-- ===================================================================== -->


  <New id="properties" class="java.util.Properties">
    <Call name="load">
      <Arg>
        <New class="java.io.FileInputStream">
          <Arg><Property name="jetty.base"/>/resources/hotrod-client.properties</Arg>
        </New>
      </Arg>
    </Call>
  </New>


  <!-- ===================================================================== -->
  <!-- Convert properties to configuration.                                  -->
  <!-- ===================================================================== -->
  <New class="org.infinispan.client.hotrod.configuration.ConfigurationBuilder">
    <Call name="withProperties">
      <Arg><Ref refid="properties"/></Arg>
    </Call>
    <Call name="marshaller">
      <Arg>
          <New class="org.infinispan.commons.marshall.ProtoStreamMarshaller"/>
       </Arg>
    </Call>
    <Call name="addContextInitializer">
        <Arg>
            <New class="org.eclipse.jetty.session.infinispan.InfinispanSerializationContextInitializer"/>
        </Arg>
    </Call>
    <Call id="config" name="build"/>
  </New>

  <!-- ===================================================================== -->
  <!-- Get a reference to the remote cachemanager.                           -->
  <!-- ===================================================================== -->
  <New id="remoteCacheManager" class="org.infinispan.client.hotrod.RemoteCacheManager">
    <Arg><Ref refid="config"/></Arg>
  </New>

  <!-- ===================================================================== -->
  <!-- Get a reference to the remote cache.                                  -->
  <!-- ===================================================================== -->
  <Ref refid="remoteCacheManager">
    <Call id="cache" name="getCache">
      <Arg><Property name="jetty.session.infinispan.remoteCacheName" default="sessions"/></Arg>
    </Call>
  </Ref>

  <!-- ===================================================================== -->
  <!-- Set queryMgrFactory reference to RemoteQueryManagerFactory            -->
  <!-- ===================================================================== -->
  <New id="queryMgrFactory" class="org.eclipse.jetty.session.infinispan.RemoteQueryManagerFactory"/>

</Configure>
