使用 aspectj 处理拦截 aop, 需要获取实现类接口上的注解
- public Object around(ProceedingJoinPoint pjp) throws Throwable{
- long time1=System.currentTimeMillis();
- String className=pjp.getTarget().getClass().getSimpleName();
- String methodName=pjp.getSignature().getName();
- Object[] args=pjp.getArgs();
- Class<?> classTarget=pjp.getTarget().getClass();
- Class<?>[] par=((MethodSignature) pjp.getSignature()).getParameterTypes();
- Method objMethod=classTarget.getMethod(methodName, par);
- Cache aCache=objMethod.getAnnotation(Cache.class);
- if(aCache!=null){
- System.out.println("-----------------");
- System.out.println("----------------- 获取注解实现类上的注解");
- System.out.println("-----------------");
- }
- }
来源: http://www.bubuko.com/infodetail-3300787.html