<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
/**********************************************************************************
 * $URL:  $
 * $Id:  $
 ***********************************************************************************
 *
 * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
 *
 * Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.php
 *
 * 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>
 

  <bean id="org.sakaiproject.search.api.SearchService"
    class="org.sakaiproject.search.component.service.impl.SearchServiceImpl" 
    init-method="init" >
    <property name="indexStorage"><ref bean="org.sakaiproject.search.index.IndexStorage" /></property>
    <property name="filter"><ref bean="searchSecurityFilterImpl" /></property>
    <property name="defaultSorter"><value>none</value></property>
    <property name="luceneSorters">
      <map>
        <entry key="dateRelevanceSort"><ref bean="dateRelevanceSort"/></entry>
      </map>
    </property>
  </bean> 
     
  <bean id="org.sakaiproject.search.api.SearchIndexBuilder"
    class="org.sakaiproject.search.component.service.impl.SearchIndexBuilderImpl" 
    init-method="init" >
    <property name="searchBuilderItemDao"><ref bean="searchBuilderItemDao" /></property>
  </bean>

  <bean id="org.sakaiproject.search.api.SearchIndexBuilderWorker"
    class="org.sakaiproject.search.component.service.impl.SearchIndexBuilderWorkerImpl" 
    init-method="init" destroy-method="destroy">
    <property name="sleepTime"><value>30000</value></property>
    <property name="dataSource">
      <ref bean="javax.sql.DataSource"/>      
    </property>
    <property name="searchIndexBuilderWorkerDao"><ref bean="searchIndexBuilderWorkerDaoJdbcImpl" /></property>
  </bean>

 <bean id="org.sakaiproject.springframework.orm.hibernate.impl.AdditionalHibernateMappingsImpl.search"
    class="org.sakaiproject.springframework.orm.hibernate.impl.AdditionalHibernateMappingsImpl">

    <property name="mappingResources">
      <list>
        <value>org/sakaiproject/search/model/impl/search.hbm.xml</value>
      </list>
    </property>
  </bean>

  
  <!-- START NEW STUFF -->
  <!-- Register the Data Access Object as a Transactional Interceptor -->
  <bean id="searchBuilderItemDao"
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager"><ref
      bean="org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager"/>
    </property>
    <property name="transactionAttributes">
      <props>
        <prop key="update*">PROPAGATION_REQUIRED</prop>
        <prop key="delete*">PROPAGATION_REQUIRED</prop>
      </props>
    </property>
    <property name="target"><ref bean="searchBuilderItemDaoImpl"/></property>
  </bean>
  
  <bean id="searchBuilderItemDaoImpl"
    class="org.sakaiproject.search.component.dao.impl.SearchBuilderItemDaoImpl" singleton="true">
    <property name="sessionFactory"><ref
      bean="org.sakaiproject.springframework.orm.hibernate.GlobalSessionFactory"/>
    </property>
  </bean>
  
  <!-- JDBC Version -->
  <bean id="searchIndexBuilderWorkerDaoJdbcImpl"
    class="org.sakaiproject.search.component.dao.impl.SearchIndexBuilderWorkerDaoJdbcImpl" 
    init-method="init" >
    <property name="dataSource">
      <ref bean="javax.sql.DataSource"/>      
    </property>
    <property name="indexStorage"><ref bean="org.sakaiproject.search.index.IndexStorage" /></property>
  </bean>
  
  <!--
    To select a differnt Storage Mechanism you can use sakai.properties    
    indexStorageName@org.sakaiproject.search.index.IndexStorage = filesystem
  -->
  
  <bean id="org.sakaiproject.search.index.IndexStorage" 
    class="org.sakaiproject.search.index.impl.SearchIndexStorage" 
    init-method="init"
    >
    <property name="defaultIndexStorage"><ref bean="filesystemSearchStorageImpl" /></property>
    <property name="indexStorageName"><value>cluster</value></property>    
    <property name="recoverCorruptedIndex"><value>true</value></property>
    <property name="currentStores">
      <map>
        <entry key="filesystem"><ref bean="filesystemSearchStorageImpl"/></entry>
        <entry key="cluster"><ref bean="clusterSearchStorageImpl"/></entry>
      </map>
    </property>
  </bean>
  
  
  
  <bean id="filesystemSearchStorageImpl" 
    class="org.sakaiproject.search.index.impl.FSIndexStorage" 
    init-method="init" >
    <property name="location"><value>${sakai.home}searchindex</value></property>
    <property name="analyzerFactory" ><ref bean="org.sakaiproject.search.index.AnalyzerFactory" /></property>    
  </bean>

  <bean id="clusterSearchStorageImpl" 
    class="org.sakaiproject.search.index.impl.ClusterFSIndexStorage" 
    init-method="init" >
    <property name="location"><value>${sakai.home}searchindex</value></property>
    <property name="analyzerFactory" ><ref bean="org.sakaiproject.search.index.AnalyzerFactory" /></property>    
    <property name="clusterFS" ><ref bean="org.sakaiproject.search.api.SearchService.SegmentStore" /></property>    
  </bean>
  
  <!--
  This is a cluster FS implementation 
  -->
  <bean id="org.sakaiproject.search.api.SearchService.SegmentStore" 
    class="org.sakaiproject.search.index.impl.JDBCClusterIndexStore" 
    init-method="init" >
    <property name="location"><value>${sakai.home}searchindex</value></property>
    <property name="dataSource"><ref bean="javax.sql.DataSource"/></property>
    <property name="autoDdl"><value>${auto.ddl}</value></property>
  </bean>
  
  
  
  <!--
    to select a different storage mecahnism do this in sakai.properties
    analyzerFactoryName@org.sakaiproject.search.index.AnalyzerFactory=snowball
  -->
  <bean id="org.sakaiproject.search.index.AnalyzerFactory" 
    class="org.sakaiproject.search.index.impl.SearchAnalyzerFactory" 
    init-method="init"
    >
    <property name="defaultAnalyzerFactory"><ref bean="snowballSearchAnalyzerImpl" /></property>
    <property name="analyzerFactoryName"><value>filesystem</value></property>    
    <property name="currentAnalyzers">
      <map>
        <entry key="snowball"><ref bean="snowballSearchAnalyzerImpl"/></entry>
      </map>
    </property>
  </bean>
  
  <bean id="snowballSearchAnalyzerImpl" 
    class="org.sakaiproject.search.index.impl.SnowballAnalyzerFactory" 
    >
    
  </bean>
  
  
  <!--
  ==============================RESULT FILTERS===============================
  -->

  <bean id="searchSecurityFilterImpl" 
    class="org.sakaiproject.search.filter.impl.SearchSecurityFilter" 
    init-method="init">
    <property name="searchIndexBuilder"><ref bean="org.sakaiproject.search.api.SearchIndexBuilder" /></property>
  </bean>
  
  <bean id="dateRelevanceSort" 
    class="org.sakaiproject.search.filter.impl.DateRelevanceSort" >
  </bean>
  
</beans>
