AOP定义
术语:切面,连接点,切入点,通知,目标对象,代理
创建通知:
前置通知类实现MethodBeforeAdvice接口
后置通知,AfterReturningAdvice接口
拦截通知,MethodInterceptor接口
异常通知,ThrowsAdvice接口
<?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 http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="customerTarget" class="aop.beforeAdvice.Customer"> <property name="name"> <value>Gates</value> </property> </bean> <bean id="welcomeAdvice" class="aop.beforeAdvice.Welcome"> </bean> <bean id="customer" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="interceptorNames"> <list> <value>welcomeAdvice</value> </list> </property> <property name="target"> <ref bean="customerTarget"/> </property> </bean> </beans>