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

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

  <!-- ===================================================================== -->
  <!-- Read hotrod-client.properties file                                    -->
  <!-- ===================================================================== -->
  <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="hotrodMgr" class="org.infinispan.client.hotrod.RemoteCacheManager">
    <Arg><Ref refid="config"/></Arg>
  </New>

  <!-- ===================================================================== -->
  <!-- Get a reference to the remote cache.                                  -->
  <!-- ===================================================================== -->
  <Ref refid="hotrodMgr">
    <Call id="cache" name="getCache">
      <Arg><Property name="jetty.session.infinispan.remoteCacheName" default="sessions"/></Arg>
    </Call>
  </Ref>
  
  <!-- ===================================================================== -->
  <!-- Set queryMgrFactory reference to NullQueryManagerFactory              -->
  <!-- ===================================================================== -->
  <New id="queryMgrFactory" class="org.eclipse.jetty.session.infinispan.NullQueryManagerFactory"/>
  
</Configure> 
