Spring学习笔记7——xml AOP

对应于java类的配置方式,同样可以使用xml的方式实现AOP。实现差不多,不多说。

package com.glodon.springdemo7;


import org.aspectj.lang.ProceedingJoinPoint;

public class SimpleProfiler {

  public void profilerBefore() throws Throwable {
    System.out.println("profiler before");
  }

  public void profilerAfter() throws Throwable {
    System.out.println("profiler after");
  }

  public void profilerAfterReturning() throws Throwable {
    System.out.println("profiler after returning");
  }

  public void profilerException() throws Throwable {
    System.out.println("profiler exception");
  }

  public Object profilerAround(ProceedingJoinPoint joinPoint) throws Throwable {
    System.out.println("profiler around start");
    Object obj = joinPoint.proceed();
    System.out.println("profiler around end");
    return obj;
  }
}

xml配置文件:




  

  

  
    

      

      

      

      

      

      

    
  

 

你可能感兴趣的:(Spring,java)