All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tosan.tools.tracker.starter.util.AnnotationUtil Maven / Gradle / Ivy

The newest version!
package com.tosan.tools.tracker.starter.util;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.aop.support.AopUtils;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

/**
 * @author F.Ebrahimi
 * @since 2/5/2024
 */
public class AnnotationUtil {

    public  T getAnnotation(ProceedingJoinPoint ctx, Class clazz) {
        MethodSignature methodSignature = (MethodSignature) ctx.getSignature();
        Method method = methodSignature.getMethod();
        Method meth = AopUtils.getMostSpecificMethod(method, ctx.getTarget().getClass());
        return (T) meth.getAnnotation(clazz);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy