<?xml version="1.0" encoding="UTF-8"?>

<!--
  - Application context containing business beans.
  -
  - Used by all artifacts.
  -
  - $Id$
  -->

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
        <property name="url" value="jdbc:hsqldb:mem:test"/>
        <!-- <value>jdbc:hsqldb:hsql://localhost/acl</value> -->
        <property name="username" value="sa"/>
        <property name="password" value=""/>
    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />
<!--
    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <property name="transactionManager" ref="transactionManager"/>
        <property name="transactionAttributeSource">
          <value>
            sample.contact.ContactManager.create=PROPAGATION_REQUIRED
            sample.contact.ContactManager.getAllRecipients=PROPAGATION_REQUIRED,readOnly
            sample.contact.ContactManager.getAll=PROPAGATION_REQUIRED,readOnly
            sample.contact.ContactManager.getById=PROPAGATION_REQUIRED,readOnly
            sample.contact.ContactManager.delete=PROPAGATION_REQUIRED
            sample.contact.ContactManager.deletePermission=PROPAGATION_REQUIRED
            sample.contact.ContactManager.addPermission=PROPAGATION_REQUIRED
          </value>
        </property>
    </bean>
 -->
    <bean id="dataSourcePopulator" class="sample.contact.DataSourcePopulator">
        <property name="dataSource" ref="dataSource"/>
        <property name="mutableAclService" ref="aclService"/>
        <property name="platformTransactionManager" ref="transactionManager"/>
    </bean>

    <bean id="contactManager" class="sample.contact.ContactManagerBackend">
<!--
       <sec:intercept-methods access-decision-manager-ref="businessAccessDecisionManager">
           <sec:protect method="sample.contact.ContactManager.create" access="ROLE_USER"/>
           <sec:protect method="sample.contact.ContactManager.getAllRecipients" access="ROLE_USER"/>
           <sec:protect method="sample.contact.ContactManager.getAll" access="ROLE_USER,AFTER_ACL_COLLECTION_READ"/>
           <sec:protect method="sample.contact.ContactManager.getById" access="ROLE_USER,AFTER_ACL_READ"/>
           <sec:protect method="sample.contact.ContactManager.delete" access="ACL_CONTACT_DELETE"/>
           <sec:protect method="sample.contact.ContactManager.deletePermission" access="ACL_CONTACT_ADMIN"/>
           <sec:protect method="sample.contact.ContactManager.addPermission" access="ACL_CONTACT_ADMIN"/>
       </sec:intercept-methods>
 -->
       <property name="contactDao">
            <bean class="sample.contact.ContactDaoSpring">
               <property name="dataSource" ref="dataSource"/>
            </bean>
        </property>
        <property name="mutableAclService" ref="aclService"/>
   </bean>

</beans>
