配置在springmvc的配置文件里,不是spring的配置文件
<aop:aspectj-autoproxy />
<bean id="logAspect" class="com.sblog.aop.Logger" />
切面类:
/**
*
*/
package com.sblog.aop;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
/**
* @author chaminda
* <p/>
* date 11/12/2013
*/
@Aspect
public class Logger {
@Before("execution(* com.sblog.service.*.get*(..))")
public void logBefore(JoinPoint joinPoint) {
System.out.println("Before:" + joinPoint.getSignature().getName());
}
@After("execution(* com.sblog.service.*.get*(..))")
public void logAfter(JoinPoint joinPoint) {
System.out.println("After:" + joinPoint.getSignature().getName());
}
@Around("execution(* com.sblog.service.*.get*(..))")
public void logAround(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("Around : "
+ joinPoint.getSignature().getName());
joinPoint.proceed(); // continue on the intercepted method
System.out.println("Around Advice - After JointPoint ");
}
}