<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

   <import resource="classpath:test/alfresco/test-context.xml" />

   <!-- load hibernate configuration properties -->
   <bean id="testHibernateConfigProperties"
      class="org.springframework.beans.factory.config.PropertiesFactoryBean">
      <!--  Load in hibernate defaults -->
      <property name="locations">
         <list>
            <value>classpath:test/alfresco/test-hibernate-cfg.properties</value>
         </list>
      </property>
      <property name="localOverride">
         <value>true</value>
      </property>
   </bean>

   <!-- Datasource bean -->
   <bean id="testDataSource" class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close">
      <property name="driverClassName">
         <value>${db.driver}</value>
      </property>
      <property name="url">
         <value>${db.testurl}</value>
      </property>
      <property name="username">
         <value>${db.username}</value>
      </property>
      <property name="password">
         <value>${db.password}</value>
      </property>
      <property name="initialSize">
         <value>${db.pool.initial}</value>
      </property>
      <property name="maxActive">
         <value>${db.pool.max}</value>
      </property>
      <property name="minIdle">
         <value>${db.pool.min}</value>
      </property>
      <property name="maxIdle">
         <value>${db.pool.idle}</value>
      </property>
      <property name="defaultAutoCommit">
         <value>false</value>
      </property>
      <property name="defaultTransactionIsolation">
         <value>${db.txn.isolation}</value>
      </property>
      <property name="maxWait">
         <value>${db.pool.wait.max}</value>
      </property>
      <property name="validationQuery">
         <value>${db.pool.validate.query}</value>
      </property>
      <property name="timeBetweenEvictionRunsMillis">
         <value>${db.pool.evict.interval}</value>
      </property>
      <property name="minEvictableIdleTimeMillis">
         <value>${db.pool.evict.idle.min}</value>
      </property>
      <property name="testOnBorrow">
         <value>${db.pool.validate.borrow}</value>
      </property>
      <property name="testOnReturn">
         <value>${db.pool.validate.return}</value>
      </property>
      <property name="testWhileIdle">
         <value>${db.pool.evict.validate}</value>
      </property>
      <property name="removeAbandoned">
         <value>${db.pool.abandoned.detect}</value>
      </property>
      <property name="removeAbandonedTimeout">
         <value>${db.pool.abandoned.time}</value>
      </property>
      <property name="poolPreparedStatements">
         <value>${db.pool.statements.enable}</value>
      </property>
      <property name="maxOpenPreparedStatements">
         <value>${db.pool.statements.max}</value>
      </property>
   </bean>

   <!-- Hibernate session factory -->
   <bean id="testSessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
         <ref bean="testDataSource" />
      </property>
      <property name="schemaUpdate">
         <value>true</value>
      </property>
      <!--
         <property name="eventListeners" > <map> <entry key="load">
         <list> <ref bean="defaltOnLoadListsner" /> <ref
         bean="clearCGLibThreadLocal" /> </list> </entry> </map>
         </property>
      -->
      <property name="mappingResources">
         <list>

            <!--  -->
            <!-- JBoss jBPM Workflow Engine -->
            <!--  -->
            <!--
               TODO: Determine if it's possible to inject the following
               mappings
            -->
            <!--       from elsewhere -->
            <!--  -->
            <value>org/jbpm/graph/action/Script.hbm.xml</value>
            <value>org/jbpm/db/hibernate.queries.hbm.xml</value>
            <value>org/jbpm/graph/def/ProcessDefinition.hbm.xml</value>
            <value>org/jbpm/graph/def/Node.hbm.xml</value>
            <value>org/jbpm/graph/def/Transition.hbm.xml</value>
            <value>org/jbpm/graph/def/Event.hbm.xml</value>
            <value>org/jbpm/graph/def/Action.hbm.xml</value>
            <value>org/jbpm/graph/def/SuperState.hbm.xml</value>
            <value>org/jbpm/graph/def/ExceptionHandler.hbm.xml</value>
            <value>org/jbpm/instantiation/Delegation.hbm.xml</value>
            <value>org/jbpm/graph/node/StartState.hbm.xml</value>
            <value>org/jbpm/graph/node/EndState.hbm.xml</value>
            <value>org/jbpm/graph/node/ProcessState.hbm.xml</value>
            <value>org/jbpm/graph/node/Decision.hbm.xml</value>
            <value>org/jbpm/graph/node/Fork.hbm.xml</value>
            <value>org/alfresco/repo/workflow/jbpm/jbpm.Join.hbm.xml</value>
            <value>org/jbpm/graph/node/State.hbm.xml</value>
            <value>org/jbpm/graph/node/TaskNode.hbm.xml</value>
            <value>org/jbpm/context/def/ContextDefinition.hbm.xml</value>
            <value>org/jbpm/context/def/VariableAccess.hbm.xml</value>
            <value>org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml</value>
            <value>org/jbpm/taskmgmt/def/Swimlane.hbm.xml</value>
            <value>org/jbpm/taskmgmt/def/Task.hbm.xml</value>
            <value>org/jbpm/taskmgmt/def/TaskController.hbm.xml</value>
            <value>org/jbpm/module/def/ModuleDefinition.hbm.xml</value>
            <value>org/jbpm/bytes/ByteArray.hbm.xml</value>
            <value>org/jbpm/file/def/FileDefinition.hbm.xml</value>
            <value>org/alfresco/repo/workflow/jbpm/jbpm.CreateTimerAction.hbm.xml</value>
            <value>org/jbpm/scheduler/def/CancelTimerAction.hbm.xml</value>
            <value>org/jbpm/graph/exe/Comment.hbm.xml</value>
            <value>org/jbpm/graph/exe/ProcessInstance.hbm.xml</value>
            <value>org/jbpm/graph/exe/Token.hbm.xml</value>
            <value>org/jbpm/graph/exe/RuntimeAction.hbm.xml</value>
            <value>org/jbpm/module/exe/ModuleInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/ContextInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/TokenVariableMap.hbm.xml</value>
            <value>org/jbpm/context/exe/VariableInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml</value>
            <value>org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml</value>
            <value>org/jbpm/job/Job.hbm.xml</value>
            <value>org/jbpm/job/Timer.hbm.xml</value>
            <value>org/alfresco/repo/workflow/jbpm/jbpm.Timer.hbm.xml</value>
            <value>org/jbpm/job/ExecuteNodeJob.hbm.xml</value>
            <value>org/jbpm/job/ExecuteActionJob.hbm.xml</value>
            <value>org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml</value>
            <value>org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml</value>
            <value>org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.hbm.xml</value>
            <value>org/jbpm/taskmgmt/exe/PooledActor.hbm.xml</value>
            <value>org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml</value>
            <value>org/jbpm/logging/log/ProcessLog.hbm.xml</value>
            <value>org/jbpm/logging/log/MessageLog.hbm.xml</value>
            <value>org/jbpm/logging/log/CompositeLog.hbm.xml</value>
            <value>org/jbpm/graph/log/ActionLog.hbm.xml</value>
            <value>org/jbpm/graph/log/NodeLog.hbm.xml</value>
            <value>org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml</value>
            <value>org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml</value>
            <value>org/jbpm/graph/log/ProcessStateLog.hbm.xml</value>
            <value>org/jbpm/graph/log/SignalLog.hbm.xml</value>
            <value>org/jbpm/graph/log/TokenCreateLog.hbm.xml</value>
            <value>org/jbpm/graph/log/TokenEndLog.hbm.xml</value>
            <value>org/jbpm/graph/log/TransitionLog.hbm.xml</value>
            <value>org/jbpm/context/log/VariableLog.hbm.xml</value>
            <value>org/jbpm/context/log/VariableCreateLog.hbm.xml</value>
            <value>org/jbpm/context/log/VariableDeleteLog.hbm.xml</value>
            <value>org/jbpm/context/log/VariableUpdateLog.hbm.xml</value>
            <value>org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml</value>
            <value>org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml</value>
            <value>org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml</value>
            <value>org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml</value>
            <value>org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml</value>
            <value>org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml</value>
            <value>org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml</value>
            <value>org/jbpm/taskmgmt/log/TaskLog.hbm.xml</value>
            <value>org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml</value>
            <value>org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml</value>
            <value>org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml</value>
            <value>org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml</value>
            <value>org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml</value>
            <value>org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml</value>
            <value>org/jbpm/job/CleanUpProcessJob.hbm.xml</value>
         </list>
      </property>
      <property name="hibernateProperties" ref="testHibernateConfigProperties" />
   </bean>

   <!-- create a transaction manager -->
   <bean id="testTransactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="transactionSynchronizationName">
         <value>SYNCHRONIZATION_ALWAYS</value>
      </property>
      <property name="sessionFactory">
         <ref bean="testSessionFactory" />
      </property>
   </bean>

</beans>
