<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you 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.
  -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/task
           http://www.springframework.org/schema/task/spring-task-3.0.xsd
           http://www.springframework.org/schema/util
           http://www.springframework.org/schema/util/spring-util.xsd">

  <context:property-placeholder location="classpath:application.properties" />

  <alias name="userConfiguration#archiva" alias="userConfiguration#default" />

  <alias name="authorizer#rbac" alias="authorizer#default"/>

  <alias name="repositoryStatisticsManager#default" alias="repositoryStatisticsManager"/>

  <alias name="environmentCheck#archiva-locked-admin-check" alias="environmentCheck#locked-admin-check"/>
  <alias name="userManager#archiva" alias="userManager#default"/>
  <alias name="authenticator#archiva" alias="authenticator#user-manager"/>
  <alias name="rbacManager#archiva" alias="rbacManager#default"/>

  <alias name="ldapConnectionFactory#archiva" alias="ldapConnectionFactory"/>
  <alias name="ldapConnectionFactory#archiva" alias="ldapConnectionFactory#configurable"/>
  
  <alias name="ldapRoleMapperConfiguration#archiva" alias="ldapRoleMapperConfiguration#default"/>


  <bean id="loggerManager" class="org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager"
        init-method="initialize"/>

  <!-- only here to cleanup temp indexes for groups increase number if use for something else -->
  <task:executor id="springExecutor" pool-size="2"/>
  <task:scheduler id="springScheduler" pool-size="2"/>
  <task:annotation-driven executor="springExecutor" scheduler="springScheduler"/>

  <bean id="mailSession" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/mail/Session">
    </property>
  </bean>

  <bean name="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="session" ref="mailSession"/>
  </bean>

  <!-- START SNIPPET: configuration-files-list -->
  <bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry"
    init-method="initialize">
    <property name="properties">
      <value>
        <![CDATA[
        <configuration>
          <system/>
          <jndi prefix="java:comp/env" config-optional="true"/>
          <xml fileName="${user.home}/.m2/archiva.xml" config-optional="true"
               config-name="org.apache.archiva.user"
               config-at="org.apache.archiva"/>
          <xml fileName="${user.home}/.m2/shared.xml" config-optional="true"
               config-name="org.apache.maven.shared.app.user" config-at="org.apache.maven.shared.app"
               config-forceCreate="true"/>
          <properties fileName="${user.home}/.m2/security.properties" config-optional="true"
                      config-at="org.apache.archiva.redback"/>
          <properties fileName="${user.home}/.m2/archiva.properties" config-optional="true"
                      config-at="org.apache.archiva.redback"/>
          <xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true"
               config-name="org.apache.archiva.base"
               config-at="org.apache.archiva"/>
          <xml fileName="${appserver.base}/conf/shared.xml" config-optional="true"
               config-name="org.apache.maven.shared.app.base" config-at="org.apache.maven.shared.app"/>
          <xml fileName="${appserver.base}/conf/common.xml" config-optional="true"/>
          <properties fileName="${appserver.base}/conf/security.properties" config-optional="true"
                      config-at="org.apache.archiva.redback"/>
          <xml fileName="${appserver.home}/conf/archiva.xml" config-optional="true"
               config-at="org.apache.archiva"/>
          <xml fileName="${appserver.home}/conf/shared.xml" config-optional="true"
               config-at="org.apache.maven.shared.app"/>
          <xml fileName="${appserver.home}/conf/common.xml" config-optional="true"/>
          <properties fileName="${appserver.home}/conf/security.properties" config-optional="true"
                      config-at="org.apache.archiva.redback"/>
          <properties fileName="org/apache/archiva/redback-security.properties" config-at="org.apache.archiva.redback"/>
        </configuration>
        ]]>
      </value>
    </property>    
  </bean>
  <!-- END SNIPPET: configuration-files-list -->

  <bean name="jdoFactory#users" class="org.apache.archiva.redback.components.jdo.DataSourceConfigurableJdoFactory">
    <property name="connectionFactoryName" value="java:comp/env/jdbc/users"/>
    <property name="shutdownConnectionFactoryName" value="java:comp/env/jdbc/usersShutdown"/>
    <property name="persistenceManagerFactoryClass" value="org.jpox.PersistenceManagerFactoryImpl"/>
    <property name="otherProperties">
      <props>
        <prop key="org.jpox.autoCreateSchema">true</prop>
        <prop key="org.jpox.validateTables">false</prop>
        <prop key="org.jpox.validateConstraints">false</prop>
        <prop key="org.jpox.validateColumns">false</prop>
        <prop key="org.jpox.autoStartMechanism">None</prop>
        <prop key="org.jpox.transactionIsolation">READ_COMMITTED</prop>
        <prop key="org.jpox.poid.transactionIsolation">READ_COMMITTED</prop>
        <prop key="org.jpox.rdbms.dateTimezone">JDK_DEFAULT_TIMEZONE</prop>
        <!-- NEEDED FOR MYSQL UTF-8 Databases -->
        <prop key="org.jpox.rdbms.stringDefaultLength">255</prop>

        <!-- NEEDED FOR POSTGRES, But causes problems in other JDBC implementations.
        <prop key="org.jpox.identifier.case">PreserveCase</prop>
        -->

        <!-- cache activation -->
        <prop key="org.jpox.cache.level2">true</prop>
        <prop key="org.jpox.cache.level2.type">ehcacheclassbased</prop>
        <prop key="org.jpox.cache.level2.cacheName">defaultJpox</prop>
        <prop key="org.jpox.cache.level2.configurationFile">/ehcache.xml</prop>
      </props>
    </property>
  </bean>


  <bean name="scheduler" class="org.apache.archiva.redback.components.scheduler.DefaultScheduler">
    <property name="properties">
      <props>
        <prop key="org.quartz.scheduler.instanceName">scheduler1</prop>
        <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
        <prop key="org.quartz.threadPool.threadCount">2</prop>
        <prop key="org.quartz.threadPool.threadPriority">4</prop>
        <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
      </props>
    </property>
  </bean>



  <!--
  <bean name="mimeTpes" class="org.apache.archiva.webdav.util.MimeTypes">
    <property name="resource" value="archiva-mime-types.txt"/>
  </bean>
  -->
  <!-- for change configuration of the users cache -->
  <bean name="cache#users" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="usersCache"/>
    <property name="timeToIdleSeconds" value="14400"/>
    <property name="timeToLiveSeconds" value="14400"/>
  </bean>



  <bean name="cache#url-failures-cache" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache" lazy-init="true"
        destroy-method="dispose">
    <property name="diskExpiryThreadIntervalSeconds" value="600"/>
    <property name="diskPersistent" value="true"/>
    <property name="diskStorePath" value="${java.io.tmpdir}/archiva/urlcache"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="url-failures-cache"/>
    <property name="overflowToDisk" value="false"/>
    <!-- 45 minutes = 2700 seconds -->
    <property name="timeToIdleSeconds" value="2700"/>
    <!-- 30 minutes = 1800 seconds  -->
    <property name="timeToLiveSeconds" value="1800"/>
  </bean>

  <bean name="cache#keys" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="keys"/>
    <property name="timeToIdleSeconds" value="1800"/>
    <property name="timeToLiveSeconds" value="14400"/>
  </bean>

  <bean name="cache#operations" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="operations"/>
    <property name="timeToIdleSeconds" value="1800"/>
    <property name="timeToLiveSeconds" value="14400"/>
  </bean>

  <bean name="cache#permissions" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="permissions"/>
    <property name="timeToIdleSeconds" value="1800"/>
    <property name="timeToLiveSeconds" value="14400"/>
  </bean>

  <bean name="cache#resources" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="resources"/>
    <property name="timeToIdleSeconds" value="1800"/>
    <property name="timeToLiveSeconds" value="14400"/>
  </bean>

  <bean name="cache#roles" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="roles"/>
    <property name="timeToIdleSeconds" value="1800"/>
    <property name="timeToLiveSeconds" value="14400"/>
  </bean>

  <bean name="cache#effectiveRoleSet" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="effectiveRoleSet"/>
    <property name="timeToIdleSeconds" value="1800"/>
    <property name="timeToLiveSeconds" value="14400"/>
  </bean>

  <!-- ================================================================
         Caches with Short Term entries
       ================================================================ -->

  <bean name="cache#userAssignments" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="userAssignments"/>
    <property name="timeToIdleSeconds" value="300"/>
    <property name="timeToLiveSeconds" value="600"/>
  </bean>

  <bean name="cache#userPermissions" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="userPermissions"/>
    <property name="timeToIdleSeconds" value="300"/>
    <property name="timeToLiveSeconds" value="600"/>
  </bean>

  <bean name="cache#ldapRoles" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="ldapRoles"/>
    <property name="timeToIdleSeconds" value="300"/>
    <property name="timeToLiveSeconds" value="600"/>
  </bean>

  <bean name="cache#namespaces" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
        init-method="initialize">
    <property name="diskPersistent" value="false"/>
    <property name="eternal" value="false"/>
    <property name="maxElementsInMemory" value="1000"/>
    <property name="memoryEvictionPolicy" value="LRU"/>
    <property name="name" value="namespaces"/>
    <property name="timeToIdleSeconds" value="600"/>
    <property name="timeToLiveSeconds" value="600"/>
  </bean>

  <!-- override jcr repository location -->
  <!-- START SNIPPET: jcr-location -->
  <!--
  <bean id="jcr-config" class="org.apache.archiva.metadata.repository.jcr.ArchivaJcrRepositoryConfig" factory-method="create">
    <constructor-arg value="${appserver.base}/conf/repository.xml"/>
    <constructor-arg value="${appserver.base}/data/jcr"/>
  </bean>
  -->
  <!-- END SNIPPET: jcr-location -->

  <!--

  <bean class="org.apache.sirona.spring.BeanNameMonitoringAutoProxyCreator">
    <property name="beanNames">
      <list>
        <value>Default**</value>
        <value>**#rest</value>
        <value>**#default</value>
      </list>
    </property>
  </bean>
  -->

</beans>
