AOP 설정 엘리먼트 | 목적 |
<aop:advisor> | AOP 어드바이저를 정의 한다 |
<aop:after> | After어드바이스를 정의한다.(이 어드바이스는 메서드의 예외발생 여부와 관계 없다.) |
<aop:after-returning> | After-returning 어드바이스를 정의한다. |
<aop:after-throwing> | After-throwing 어드바이스를 정의한다. |
<aop:around> | Around 어드바이스를 정의한다. |
<aop:aspect> | 애스펙트를 정의한다. |
<aop:before> | Before 어드바이스를 정의한다. |
<aop:config> | 최상위 AOP엘리번트. 대부분의 <aop:*> 엘리먼트는 이 <aop:config>안에 포함되야 한다. |
<aop:pointcut> | 포인트컷을 정의한다. |
<?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"
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">
<bean id="audience" class="chapter4.springidol.Audience" />
<aop:config>
<aop:aspect ref="audience">
<aop:before
method="takeSeats"
pointcut="execution(* *.perform(..))" />
<aop:before
method="turnOffCellPhones"
pointcut="execution(* *.perform(..))" />
<aop:after-returning
method="applaud"
pointcut="execution(* *.perform(..))" />
<aop:after-throwing
method="demandRefund"
pointcut="execution(* *.perform(..))" />
</aop:aspect>
</aop:config>
</beans>
...
<aop:config>
<aop:aspect ref="audience">
<aop:pointcut
id="performance"
expression="execution(* *.perform(..))" />
<aop:before
method="takeSeats"
pointcut-ref="performance" />
<aop:before
method="turnOffCellPhones"
pointcut-ref="performance" />
<aop:after-returning
method="applaud"
pointcut-ref="performance" />
<aop:after-throwing
method="demandRefund"
pointcut-ref="performance" />
</aop:aspect>
</aop:config>
...