com.github.frtu.simple.infra.reflect.ClassPathScanningAnnotationProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simple-infra Show documentation
Show all versions of simple-infra Show documentation
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 extends Annotation> annotationType) {
return findCandidateComponents(annotationType, "");
}
public static Set findCandidateComponents(Class extends Annotation> 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