Commit 1bd1ffdb authored by Phillip Webb's avatar Phillip Webb

Polish

parent 34156b21
......@@ -83,27 +83,6 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
this.beanFactory = beanFactory;
}
/**
* Factory method to get the {@link BeanTypeRegistry} for a given {@link BeanFactory}.
* @param beanFactory the source bean factory
* @return the {@link BeanTypeRegistry} for the given bean factory
*/
static BeanTypeRegistry get(ListableBeanFactory beanFactory) {
Assert.isInstanceOf(DefaultListableBeanFactory.class, beanFactory);
DefaultListableBeanFactory listableBeanFactory = (DefaultListableBeanFactory) beanFactory;
Assert.isTrue(listableBeanFactory.isAllowEagerClassLoading(),
"Bean factory must allow eager class loading");
if (!listableBeanFactory.containsLocalBean(BEAN_NAME)) {
BeanDefinition bd = BeanDefinitionBuilder
.genericBeanDefinition(BeanTypeRegistry.class,
() -> new BeanTypeRegistry(
(DefaultListableBeanFactory) beanFactory))
.getBeanDefinition();
listableBeanFactory.registerBeanDefinition(BEAN_NAME, bd);
}
return listableBeanFactory.getBean(BEAN_NAME, BeanTypeRegistry.class);
}
/**
* Return the names of beans matching the given type (including subclasses), judging
* from either bean definitions or the value of {@link FactoryBean#getObjectType()} in
......@@ -113,7 +92,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
* @return the names of beans (or objects created by FactoryBeans) matching the given
* object type (including subclasses), or an empty set if none
*/
Set<String> getNamesForType(Class<?> type) {
public Set<String> getNamesForType(Class<?> type) {
updateTypesIfNecessary();
return this.beanTypes.entrySet().stream()
.filter((entry) -> entry.getValue() != null
......@@ -131,7 +110,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
* @return the names of beans (or objects created by FactoryBeans) annotated with the
* given annotation, or an empty set if none
*/
Set<String> getNamesForAnnotation(Class<? extends Annotation> annotation) {
public Set<String> getNamesForAnnotation(Class<? extends Annotation> annotation) {
updateTypesIfNecessary();
return this.beanTypes.entrySet().stream()
.filter((entry) -> entry.getValue() != null && AnnotationUtils
......@@ -352,4 +331,25 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
return null;
}
/**
* Factory method to get the {@link BeanTypeRegistry} for a given {@link BeanFactory}.
* @param beanFactory the source bean factory
* @return the {@link BeanTypeRegistry} for the given bean factory
*/
static BeanTypeRegistry get(ListableBeanFactory beanFactory) {
Assert.isInstanceOf(DefaultListableBeanFactory.class, beanFactory);
DefaultListableBeanFactory listableBeanFactory = (DefaultListableBeanFactory) beanFactory;
Assert.isTrue(listableBeanFactory.isAllowEagerClassLoading(),
"Bean factory must allow eager class loading");
if (!listableBeanFactory.containsLocalBean(BEAN_NAME)) {
BeanDefinition bd = BeanDefinitionBuilder
.genericBeanDefinition(BeanTypeRegistry.class,
() -> new BeanTypeRegistry(
(DefaultListableBeanFactory) beanFactory))
.getBeanDefinition();
listableBeanFactory.registerBeanDefinition(BEAN_NAME, bd);
}
return listableBeanFactory.getBean(BEAN_NAME, BeanTypeRegistry.class);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment