Skip to content

Commit 965bea7

Browse files
committed
DefaultListableBeanFactory efficiently accesses current bean names and exposes them via getBeanNamesIterator()
Issue: SPR-12404
1 parent 97ea436 commit 965bea7

File tree

4 files changed

+153
-82
lines changed

4 files changed

+153
-82
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.beans.factory.config;
1818

19+
import java.util.Iterator;
20+
1921
import org.springframework.beans.BeansException;
2022
import org.springframework.beans.factory.ListableBeanFactory;
2123
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -105,6 +107,20 @@ boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor)
105107
*/
106108
BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException;
107109

110+
/**
111+
* Return a unified view over all bean names managed by this factory.
112+
* <p>Includes bean definition names as well as names of manually registered
113+
* singleton instances, with bean definition names consistently coming first,
114+
* analogous to how type/annotation specific retrieval of bean names works.
115+
* @return the composite iterator for the bean names view
116+
* @since 4.1.2
117+
* @see #containsBeanDefinition
118+
* @see #registerSingleton
119+
* @see #getBeanNamesForType
120+
* @see #getBeanNamesForAnnotation
121+
*/
122+
Iterator<String> getBeanNamesIterator();
123+
108124
/**
109125
* Freeze all bean definitions, signalling that the registered bean definitions
110126
* will not be modified or post-processed any further.

0 commit comments

Comments
 (0)