SpringAop使用XML文件方式

SpringAop使用XML文件方式_第1张图片

package Calc;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;


public interface Calculator {
	public void add(int i,int j);
	public void sub(int i,int j);
	public void mul(int i,int j);
	public void div(int i,int j);
	
	public int add(int i,int j,int k);
}
package Calc;

import org.springframework.stereotype.Component;


public class CalculatorImp implements Calculator {

	public void add(int i, int j) {
		// TODO Auto-generated method stub
		int re=i+j;
		System.out.println(re);
	}

	public void sub(int i, int j) {
		// TODO Auto-generated method stub
		int re=i-j;
		System.out.println(re);
	}

	public void mul(int i, int j) {
		// TODO Auto-generated method stub
		int re=i*j;
		System.out.println(re);
	}

	public void div(int i, int j) {
		// TODO Auto-generated method stub
		int re=i/j;
		System.out.println(re);
	}

	public int add(int i, int j, int k) {
		// TODO Auto-generated method stub
		int re=i+j+k;
		
		return re;
	}

}

package Calc;

import java.lang.reflect.Array;
import java.util.Arrays;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;


public class AopDemo {

	public void bf(){
		System.out.println("bf...");
	}
	public void af(){
		System.out.println("af...");
	}
	public void ar(){
		System.out.println("error!!!");
	}
	public void areturn(){
		System.out.println("return!!!");
	}
}






	
	
		
		
		
		
	



SpringAop使用XML文件方式_第2张图片

你可能感兴趣的:(Java)