this用来限定AOP代理必须是指定类型的实例,如上,指定了一个特定的实例,就是UserService
D:@Pointcut(“bean(userService)”)
bean也是非常常用的,bean可以指定IOC容器中的bean的名称
下面是一个使用AOP获取统计计算方法执行时间以及获取request请求参数等信息的log方法:
/**
-
description:
-
统计请求执行时间
-
@author wkGui
*/
@Component
@Aspect
public class ResExeTimeCounter {
private static Logger logger = LoggerFactory.getLogger(ResExeTimeCounter.class);
@Pointcut(“execution(* com.wk.controller….(…))”)
public void pointCut() {
}
@Around(“pointCut()”)
public Object around(ProceedingJoinPoint pjp) throws Throwable {
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
assert sra != null;
HttpServletRequest reque