为什么需要AOP?

  需求加减乘除

package com.tanlei.spring.bean.Aop;

public interface AtithmeticCalculator {
    int add(int i,int j);
    int sub(int i,int j);
    int mul(int i,int j);
    int div(int i,int j);
}

 

package com.tanlei.spring.bean.Aop;

public class AtithmeticCalculatorImpl implements AtithmeticCalculator{

    @Override
    public int add(int i, int j) {
        System.out.println("the method add begin whith ["+i+","+j+"]");
        int result=i+j;
        System.out.println("the method add end whith"+result);
        return result;
    }

    @Override
    public int sub(int i, int j) {
        System.out.println("the method sub begin whith ["+i+","+j+"]");
        int result=i-j;
        System.out.println("the method sub end whith"+result);
        return result;
    }

    @Override
    public int mul(int i, int j) {
        System.out.println("the method mul begin whith ["+i+","+j+"]");
        int result=i*j;
        System.out.println("the method mul end whith"+result);
        return result;
        
    }

    @Override
    public int div(int i, int j) {
        System.out.println("the method div begin whith ["+i+","+j+"]");
        int result=i/j;
        System.out.println("the method div end whith"+result);
        return result;
    
    }

}
View Code

相关文章:

  • 2021-10-15
  • 2021-05-27
  • 2021-10-04
  • 2021-03-11
猜你喜欢
  • 2022-12-23
  • 2021-04-25
  • 2022-01-18
  • 2022-12-23
  • 2021-12-20
  • 2022-01-04
  • 2022-12-23
相关资源
相似解决方案