Java Reflection Annotation getAnnotationFromJoinpointMethod(ProceedingJoinPoint joinpoint, Class annotationClass)

Here you can find the source of getAnnotationFromJoinpointMethod(ProceedingJoinPoint joinpoint, Class annotationClass)

Description

get Annotation From Joinpoint Method

License

Apache License

Declaration

@SuppressWarnings({ "rawtypes", "unchecked" })
    public static Annotation getAnnotationFromJoinpointMethod(ProceedingJoinPoint joinpoint, Class annotationClass)
            throws SecurityException, NoSuchMethodException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.lang.annotation.Annotation;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

public class Main {
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static Annotation getAnnotationFromJoinpointMethod(ProceedingJoinPoint joinpoint, Class annotationClass)
            throws SecurityException, NoSuchMethodException {
        MethodSignature signature = (MethodSignature) joinpoint.getSignature();
        String methodName = signature.getMethod().getName();
        Class<?>[] parameterTypes = signature.getMethod().getParameterTypes();
        Annotation annotation = joinpoint.getTarget().getClass().getMethod(methodName, parameterTypes)
                .getAnnotation(annotationClass);
        return annotation;
    }/*from   w  w  w.j a v a  2s .c  om*/
}

Related

  1. getAnnotationForProperty(Class cls, String name, Class anno)
  2. getAnnotationFromAnnotation(Annotation annotation, Class annotationClass)
  3. getAnnotationFromEntityFields(Class entity, Class annotation)
  4. getAnnotationFromEntityOrInterface( Class annotationType, Class entity)
  5. getAnnotationFromField(Object object, Class annotationClass)
  6. getAnnotationFromStackTrace(Class annotationClass)
  7. getAnnotationFromWeldBean(Object target, Class annotation)
  8. getAnnotationFullname(Annotation annotation)
  9. getAnnotationInClass( final Class annotationClass, final Class clazz)