summaryrefslogtreecommitdiff
path: root/spring-framework/20-aop-xml/src/main/resources/META-INF/spring/applicationContext.xml
blob: ecf08e4ed3343581956b616ecad15bfb81106ed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?xml version="1.0" encoding="UTF-8"?>
<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:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

	<bean id="account" class="com.example.spring.aop.Account">
		<property name="accNo" value="1000"></property>
		<property name="balance" value="250.00"></property>
	</bean>

	<!-- Here is a bean representing the security aspect -->

	<bean id="accessChecker" class="com.example.spring.aop.security.AccessChecker" />

	<aop:config>
		<aop:aspect id="securityAspect" ref="accessChecker">

			<aop:pointcut id="deposit"
				expression="execution(public * com.example.spring.aop.Account.deposit(..))" />
			<aop:before pointcut-ref="deposit"
				method="checkDepositPermission" />

			<aop:pointcut id="withdraw"
				expression="execution(public * com.example.spring.aop.Account.withdraw(..)) and args(amount)" />
			<aop:before pointcut-ref="withdraw"
				method="checkWithdrawPermission(double)" />

		</aop:aspect>
 
	</aop:config>

</beans>