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

<!--
  pplication context definition for Demo18's business layer.
  -->
<beans xmlns="http://www.springframework.org/schema/beans"
	     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	     xmlns:aop="http://www.springframework.org/schema/aop"
	     xmlns:tx="http://www.springframework.org/schema/tx"
	     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">


	<!-- ========================= GENERAL DEFINITIONS ========================= -->

	<!-- Configurer that replaces ${...} placeholders with values from properties files -->
	<!-- (in this case, JDBC related properties) -->
	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>WEB-INF/jdbc.properties</value>
			</list>
		</property>
	</bean>


	<!-- ========================= BUSINESS OBJECT DEFINITIONS ======================== -->

	<!--
	  Demo18 primary business object (default implementation).
	 Transaction advice gets applied through the AOP configuration below.
	-->
	<bean id="mainFacade" class="demo18.server.DemoFacade">
		<property name="taskDao" ref="taskDao"/>
		<property name="empDao" ref="empDao"/>
		<property name="deptDao" ref="deptDao"/>
	</bean>


	<!-- ========================= ASPECT CONFIGURATION ======================== -->

	<aop:config>
		<!--
			This definition creates auto-proxy infrastructure based on the given pointcut,
			expressed in AspectJ pointcut language. Here: applying the advice named
			"txAdvice" to all methods on classes named DemoFacade.
		-->
		<aop:advisor pointcut="execution(* *..DemoFacade.*(..))" advice-ref="txAdvice"/>

	</aop:config>

	<!--
		Transaction advice definition, based on method name patterns.
		Defaults to PROPAGATION_REQUIRED for all methods whose name starts with
		"insert" or "update", and to PROPAGATION_REQUIRED with read-only hint
		for all other methods.
	-->
	<tx:advice id="txAdvice">
		<tx:attributes>
			<tx:method name="insert*"/>
			<tx:method name="update*"/>
			<tx:method name="delete*"/>
			<tx:method name="*" read-only="true"/>
		</tx:attributes>
	</tx:advice>


</beans>
