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

com.ideaaedi.commonspring.aop.AntiDuplicationPointcutAdvisor Maven / Gradle / Ivy

There is a newer version: 2100.10.6.LTS17
Show newest version
package com.ideaaedi.commonspring.aop;

import com.ideaaedi.commonspring.lite.antidupli.AntiDuplication;
import com.ideaaedi.commonspring.spi.AntiDuplicateExecutor;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.NonNull;

import java.lang.reflect.Method;

public class AntiDuplicationPointcutAdvisor extends StaticMethodMatcherPointcutAdvisor {
    
    public static final String BEAN_NAME = "antiDuplicationPointcutAdvisor";
    
    public AntiDuplicationPointcutAdvisor(@SuppressWarnings("rawtypes") @NonNull AntiDuplicateExecutor antiDuplicateExecutor) {
        AntiDuplicationAdvice advice = new AntiDuplicationAdvice(antiDuplicateExecutor);
        setAdvice(advice);
        setOrder(advice.getOrder());
    }
    
    /**
     * 定义AntiDuplication注解发现逻辑
     */
    @Override
    public boolean matches(@NonNull Method method, @NonNull Class targetClass) {
        AntiDuplication annotation = AnnotationUtils.getAnnotation(method, AntiDuplication.class);
        return annotation != null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy