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

<!--
  - Application context containing business beans.
  -
  - Used by all artifacts.
  -
  - $Id: applicationContext-common-business.xml 1930 2007-07-24 17:46:43Z luke_t $
  -->

<beans>

  <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 local="dataSource"/></property>
	</bean>

	<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
    <property name="transactionManager"><ref local="transactionManager"/></property>
		<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="org.springframework.aop.framework.ProxyFactoryBean">
     <property name="proxyInterfaces" value="sample.contact.ContactManager"/>
     <property name="interceptorNames">
       <list>
         <idref local="transactionInterceptor"/>
         <idref bean="contactManagerSecurity"/>
         <idref local="contactManagerTarget"/>
       </list>
     </property>
   </bean>

   <bean id="contactManagerTarget" class="sample.contact.ContactManagerBackend">
	   <property name="contactDao">
       <bean class="sample.contact.ContactDaoSpring">
	       <property name="dataSource"><ref local="dataSource"/></property>
       </bean>
     </property>
     <property name="mutableAclService" ref="aclService"/>
   </bean>

</beans>
