Annotation Tools

InterceptorUtils tools:

public  class InterceptorUtils {

    private static Logger logger = getLogger(InterceptorUtils.class);

    private InterceptorUtils() {
    }

    public static <A extends Annotation> A getAnnotation(Object handler, Class<A> annotationClass) {
        if (!(handler instanceof HandlerMethod)) {
            return null;
        }

        Acting Method acting method = (Handler Method) trades;
        A result;
        if ((result = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), annotationClass)) != null) {
            logger.trace("found [{}] annotation in method-level:{}",
                    annotationClass.getSimpleName(), handlerMethod.getMethod());
        } else {
            if ((result = AnnotationUtils.findAnnotation(handlerMethod.getBeanType(), annotationClass)) != null) {
                logger.trace("found [{}] annotation in type-level:{}",
                        annotationClass.getSimpleName(), handlerMethod.getBeanType());
            }
        }
        return result;
    }

}

 

Guess you like

Origin www.cnblogs.com/koushr/p/11908131.html