AOP学习

关键点:

一、

 1 @Aspect
 2 @Component
 3 public class LogAspect
 4 {
 5     @Before("execution(  * com.honliv.hp.it.aop.ArithmeticCalculatorImpl.*(int, int ))") 6     public void beforeFunction(JoinPoint joinPoint)
 7     {
 8         String funtionName = joinPoint.getSignature().getName();
 9         List<Object> parms = Arrays.asList(  joinPoint.getArgs());
10         System.out.println("Before Function " + funtionName+" parms :"+parms);
11     }
12 }

二、

beans 配置

1     <!-- 配置自动扫描的包 -->
2     <context:component-scan
3         base-package="com.honliv.hp.it.aop"></context:component-scan>
4     <!-- 使切面的注解起作用 -->
5     <aop:aspectj-autoproxy></aop:aspectj-autoproxy>

猜你喜欢

转载自www.cnblogs.com/songzhenyi/p/9357949.html