package com.hh.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAop {

// private EntityManager entityManager;

@Around("execution(* com.hh.controller..*.*(..))")
public Object aopController(ProceedingJoinPoint joinPoint) throws Throwable {

System.out.println("around");
//获取方法参数值数组
Object[] args = joinPoint.getArgs();
//得到其方法签名
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
//获取方法参数类型数组
Class[] paramTypeArray = methodSignature.getParameterTypes();
System.out.println(methodSignature.getParameterNames());
System.out.println(paramTypeArray);
Object result = joinPoint.proceed(args);
System.out.println("=====checkSecurity====");

for (int i = 0; i < joinPoint.getArgs().length; i++) {
System.out.println(joinPoint.getArgs()[i]);
}
System.out.println(joinPoint.getSignature().getName());



return result;
}
}
posted on 2021-01-13 20:42  王洪洪  阅读(290)  评论(0编辑  收藏  举报