use of cn.taketoday.context.loader.ClassPathScanningCandidateComponentProvider in project today-infrastructure by TAKETODAY.
the class ConfigurationPropertiesScanRegistrar method scan.
private void scan(BootstrapContext context, Set<String> packages) {
var registrar = new ConfigurationPropertiesBeanRegistrar(context);
ClassPathScanningCandidateComponentProvider scanner = getScanner(context);
for (String basePackage : packages) {
try {
scanner.scanCandidateComponents(basePackage, (metadataReader, factory) -> register(registrar, metadataReader));
} catch (IOException e) {
throw new IllegalStateException("ConfigurationProperties scanning failed", e);
}
}
}
use of cn.taketoday.context.loader.ClassPathScanningCandidateComponentProvider in project today-infrastructure by TAKETODAY.
the class ClassPathScanningCandidateComponentProviderTests method customFiltersFollowedByResetUseIndex.
@Test
public void customFiltersFollowedByResetUseIndex() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
provider.resetFilters(true);
Set<AnnotatedBeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
assertBeanDefinitionType(candidates);
}
use of cn.taketoday.context.loader.ClassPathScanningCandidateComponentProvider in project today-infrastructure by TAKETODAY.
the class ClassPathScanningCandidateComponentProviderTests method customSupportedIncludeAndExcludedFilterWithScan.
@Test
public void customSupportedIncludeAndExcludedFilterWithScan() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.setResourceLoader(new DefaultResourceLoader(CandidateComponentsTestClassLoader.disableIndex(getClass().getClassLoader())));
testCustomSupportedIncludeAndExcludeFilter(provider);
}
use of cn.taketoday.context.loader.ClassPathScanningCandidateComponentProvider in project today-infrastructure by TAKETODAY.
the class ClassPathScanningCandidateComponentProviderTests method customNotSupportedIncludeFilterUseScan.
@Test
public void customNotSupportedIncludeFilterUseScan() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER));
provider.addIncludeFilter(new AssignableTypeFilter(FooDao.class));
Set<AnnotatedBeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
assertThat(containsBeanClass(candidates, StubFooDao.class)).isTrue();
assertThat(candidates.size()).isEqualTo(1);
assertBeanDefinitionType(candidates);
}
use of cn.taketoday.context.loader.ClassPathScanningCandidateComponentProvider in project today-infrastructure by TAKETODAY.
the class ClassPathScanningCandidateComponentProviderTests method customAssignableTypeIncludeFilterWithScan.
@Test
public void customAssignableTypeIncludeFilterWithScan() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.setResourceLoader(new DefaultResourceLoader(CandidateComponentsTestClassLoader.disableIndex(getClass().getClassLoader())));
testCustomAssignableTypeIncludeFilter(provider);
}
Aggregations