当前位置: 移动技术网 > IT编程>开发语言>Java > AOP学习

AOP学习

2018年07月24日  | 移动技术网IT编程  | 我要评论

关键点:

一、

 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>

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网