use of cn.taketoday.context.loader.ScopeMetadata in project today-framework by TAKETODAY.
the class ClassPathBeanDefinitionScanner method scanning.
/**
* Perform a scan within the specified base packages,
* returning the registered bean definitions.
* <p>This method does <i>not</i> register an annotation config processor
* but rather leaves this up to the caller.
*
* @param basePackages the packages to check for annotated classes
* @return set of beans registered if any for tooling registration purposes (never {@code null})
*/
@Deprecated
public Set<BeanDefinition> scanning(String... basePackages) {
Assert.notEmpty(basePackages, "At least one base package must be specified");
LinkedHashSet<BeanDefinition> beanDefinitions = new LinkedHashSet<>();
for (String basePackage : basePackages) {
try {
scanCandidateComponents(basePackage, (metadataReader, metadataReaderFactory) -> {
ScannedGenericBeanDefinition candidate = new ScannedGenericBeanDefinition(metadataReader);
candidate.setSource(metadataReader.getResource());
ScopeMetadata scopeMetadata = scopeMetadataResolver.resolveScopeMetadata(candidate);
candidate.setScope(scopeMetadata.getScopeName());
AnnotationConfigUtils.processCommonDefinitionAnnotations(candidate);
String beanName = beanNamePopulator.populateName(candidate, registry);
postProcessBeanDefinition(candidate, beanName);
if (checkCandidate(beanName, candidate)) {
beanDefinitions.add(candidate);
registerBeanDefinition(candidate, registry);
}
});
} catch (IOException ex) {
throw new BeanDefinitionStoreException("I/O failure during classpath scanning", ex);
}
}
return beanDefinitions;
}
use of cn.taketoday.context.loader.ScopeMetadata in project today-framework by TAKETODAY.
the class ClassPathBeanDefinitionScanner method scan.
/**
* Perform a scan within the specified base packages and consume the registered
* bean definitions.
* <p>This method does <i>not</i> register an annotation config processor
* but rather leaves this up to the caller.
*
* @param consumer set of beans registered if any for tooling registration purposes
* @param basePackages the packages to check for annotated classes
*/
public void scan(@Nullable Consumer<BeanDefinitionHolder> consumer, String... basePackages) {
for (String basePackage : basePackages) {
try {
scanCandidateComponents(basePackage, (metadataReader, factory) -> {
ScannedGenericBeanDefinition candidate = new ScannedGenericBeanDefinition(metadataReader);
candidate.setResource(metadataReader.getResource());
ScopeMetadata scopeMetadata = scopeMetadataResolver.resolveScopeMetadata(candidate);
candidate.setScope(scopeMetadata.getScopeName());
String beanName = beanNamePopulator.populateName(candidate, registry);
postProcessBeanDefinition(candidate, beanName);
AnnotationConfigUtils.processCommonDefinitionAnnotations(candidate);
if (checkCandidate(beanName, candidate)) {
BeanDefinitionHolder holder = new BeanDefinitionHolder(candidate, beanName);
holder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, holder, registry);
if (consumer != null) {
consumer.accept(holder);
}
registerBeanDefinition(holder, registry);
}
});
} catch (IOException ex) {
throw new BeanDefinitionStoreException("I/O failure during classpath scanning", ex);
}
}
}
Aggregations