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

com.github.frtu.simple.infra.reflect.ClassPathScanningAnnotationProvider Maven / Gradle / Ivy

Go to download

Provide a set of classes for infrastructure and bootstrap that have very few dependencies that you can embedded easily into any application

The newest version!
package com.github.frtu.simple.infra.reflect;

import java.lang.annotation.Annotation;
import java.util.Set;

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AnnotationTypeFilter;

public class ClassPathScanningAnnotationProvider extends ClassPathScanningCandidateComponentProvider {
    public ClassPathScanningAnnotationProvider() {
        super(false);
    }

    @Override
    protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
        return beanDefinition.getMetadata().isIndependent();
    }

    public static Set findCandidateComponents(Class annotationType) {
        return findCandidateComponents(annotationType, "");
    }
    public static Set findCandidateComponents(Class annotationType, String basePackage) {
        ClassPathScanningAnnotationProvider classPathScanningCandidateComponentProvider = new ClassPathScanningAnnotationProvider();
        classPathScanningCandidateComponentProvider.addIncludeFilter(new AnnotationTypeFilter(annotationType));
        
        Set findCandidateComponents = classPathScanningCandidateComponentProvider.findCandidateComponents(basePackage);
        return findCandidateComponents;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy