您的位置:首页 > 其它

ProceedingJoinPoint获取实现类接口上的注解

2016-04-12 14:18 351 查看
使用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("-----------------");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: