Java Reference
In-Depth Information
To apply this audit advice, you need a
pointcut
. In AOP, a pointcut determines where
to apply this advice. You can combine an advice and pointcut into an advisor. Listing 6-24
shows the advisor for this example.
Listing 6-24.
audit-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="
http://www.springframework.org/schema/beans"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
<!--advisor -->
<bean id="auditAdvisor"
class="org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor">
<property name="advice" ref="auditAdvice" />
<property name="expression" value="execution(* *.underwrite*(..))" />
</bean>
<!—other beans -->
</beans>
As shown in Listing 6-24, the audit advice is applicable to any method starting with
the word
underwrite
. Finally, you need to create proxies for the beans matching the
expression property of the advisor. Listing 6-25 shows the automatic proxy creator bean.
Listing 6-25.
audit-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="
http://www.springframework.org/schema/beans"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
<!--advisor -->
<bean id="auditAdvisor"
class="org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor">
<property name="advice" ref="auditAdvice" />
<property name="expression" value="execution(* *.underwrite*(..))" />
</bean>
