<bean id="hello" class="org.spring.Hello"></bean>
<bean id="log" class="org.spring.Log"></bean>
<aop:config>
<aop:aspect id="log" ref="log">
<aop:pointcut id="pt" expression="execution(public void org.spring.Hello.aop())"></aop:pointcut>
<aop:around method="around" pointcut-ref="pt"></aop:around>
</aop:aspect>
</aop:config>
public Object around(ProceedingJoinPoint joinPoint){
Object[] args = joinPoint.getArgs();
Object proceed = null;
try {
System.out.println("around前置通知");
proceed = joinPoint.proceed(args);
System.out.println("后置");
} catch (Throwable throwable) {
System.out.println("异常");
throwable.printStackTrace();
}finally {
System.out.println("最终");
}
return proceed;
}
网友评论