日期:2014-05-16 浏览次数:20492 次
import java.lang.reflect.Method; import org.springframework.aop.MethodBeforeAdvice; public class DaoMethodBeforeAdvice implements MethodBeforeAdvice{ public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable { System.out.println("[DaoMethodBeforeAdvice]:" + arg0 + " : " + arg1[0]); } }
<bean id="beforeDaoAdvice" class="com.zakisoft.workspace.initcompt.advice.DaoMethodBeforeAdvice"></bean> <bean id="afterDaoAdvice" class="com.zakisoft.workspace.initcompt.advice.DaoMethodAfterAdvice"></bean> <bean id="throwsDaoAdvice" class="com.zakisoft.workspace.initcompt.advice.DaoThrowsAdvice"></bean> <bean id="aroundAdvice" class="com.zakisoft.workspace.initcompt.advice.DaoMethodAroundAdvice"></bean> <bean id="daoAopService" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target" ref="mybatisDaoBean"></property> <property name="interceptorNames"> <list> <value>beforeDaoAdvice</value> <value>afterDaoAdvice</value> <value>throwsDaoAdvice</value> <value>aroundAdvice</value> </list> </property> </bean>