<#escape x as x?xml>
<?xml version="1.0"?>
<component name="org.nuxeo.ecm.core.redis.config">
  <require>org.nuxeo.ecm.core.work.config</require>

<#if "${nuxeo.redis.enabled}" == "true">
  <extension target="org.nuxeo.ecm.core.redis"
    point="configuration">
<#if "${nuxeo.redis.ha.enabled}" == "true">
    <sentinel>
      <master>${nuxeo.redis.ha.master}</master>
      <failoverTimeout>${nuxeo.redis.ha.timeout}</failoverTimeout>
<#assign names="${nuxeo.redis.ha.hosts}"?split(",") />
<#list names as name>
      <host name="${name}" port="${nuxeo.redis.ha.port}"/>
</#list>
      <password>${nuxeo.redis.password}</password>
      <database>${nuxeo.redis.database}</database>
      <timeout>${nuxeo.redis.timeout}</timeout>
      <maxTotal>${nuxeo.redis.maxTotal}</maxTotal>
      <maxIdle>${nuxeo.redis.maxIdle}</maxIdle>
      <prefix>${nuxeo.redis.prefix}</prefix>
    </sentinel>
<#else>
    <server>
      <host>${nuxeo.redis.host}</host>
      <port>${nuxeo.redis.port}</port>
      <password>${nuxeo.redis.password}</password>
      <database>${nuxeo.redis.database}</database>
      <timeout>${nuxeo.redis.timeout}</timeout>
      <maxTotal>${nuxeo.redis.maxTotal}</maxTotal>
      <maxIdle>${nuxeo.redis.maxIdle}</maxIdle>
      <prefix>${nuxeo.redis.prefix}</prefix>
    </server>
</#if>
  </extension>

<#if "${nuxeo.pubsub.provider}" == "redis">
  <extension target="org.nuxeo.ecm.core.pubsub.PubSubService" point="configuration">
    <provider class="org.nuxeo.ecm.core.redis.contribs.RedisPubSubProvider"/>
  </extension>
</#if>

<#if "${nuxeo.keyvalue.provider}" == "redis">
  <extension target="org.nuxeo.ecm.core.storage.KeyValueService" point="configuration">
    <store name="default" class="org.nuxeo.ecm.core.redis.contribs.RedisKeyValueStore">
      <property name="namespace">kv</property>
    </store>
  </extension>
</#if>

<#if "${nuxeo.lock.manager}" == "redis">
  <extension target="org.nuxeo.ecm.core.storage.lock.LockManagerService" point="lockmanager">
    <lockmanager name="default" class="org.nuxeo.ecm.core.redis.contribs.RedisLockManager" />
  </extension>
</#if>

<#if "${nuxeo.work.queuing}" == "redis">
  <extension target="org.nuxeo.ecm.core.work.service" point="implementation">
    <queuing class="org.nuxeo.ecm.core.redis.contribs.RedisWorkQueuing"/>
  </extension>
</#if>
</#if>

</component>
</#escape>
