Skip to content

Commit 3c76437

Browse files
committed
Update RegisteredBean to take a ConfigurableListableBeanFactory
This allows to have access to `getBeanDefinition` if the original bean definition needs to be retrieved. See gh-28936
1 parent 832889d commit 3c76437

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import org.springframework.beans.factory.config.BeanDefinition;
6262
import org.springframework.beans.factory.config.BeanPostProcessor;
6363
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
64+
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
6465
import org.springframework.beans.factory.config.ConstructorArgumentValues;
6566
import org.springframework.beans.factory.config.DependencyDescriptor;
6667
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
@@ -1221,7 +1222,7 @@ private Object obtainInstanceFromSupplier(Supplier<?> supplier, String beanName)
12211222
this.currentlyCreatedBean.set(beanName);
12221223
try {
12231224
if (supplier instanceof InstanceSupplier<?> instanceSupplier) {
1224-
return instanceSupplier.get(RegisteredBean.of(this, beanName));
1225+
return instanceSupplier.get(RegisteredBean.of((ConfigurableListableBeanFactory) this, beanName));
12251226
}
12261227
if (supplier instanceof ThrowingSupplier<?> throwableSupplier) {
12271228
return throwableSupplier.getWithException();

spring-beans/src/main/java/org/springframework/beans/factory/support/RegisteredBean.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.springframework.beans.factory.BeanFactory;
2323
import org.springframework.beans.factory.config.BeanDefinition;
2424
import org.springframework.beans.factory.config.BeanDefinitionHolder;
25-
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
25+
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
2626
import org.springframework.core.ResolvableType;
2727
import org.springframework.core.style.ToStringCreator;
2828
import org.springframework.lang.Nullable;
@@ -41,7 +41,7 @@
4141
*/
4242
public final class RegisteredBean {
4343

44-
private final ConfigurableBeanFactory beanFactory;
44+
private final ConfigurableListableBeanFactory beanFactory;
4545

4646
private final Supplier<String> beanName;
4747

@@ -53,7 +53,7 @@ public final class RegisteredBean {
5353
private final RegisteredBean parent;
5454

5555

56-
private RegisteredBean(ConfigurableBeanFactory beanFactory, Supplier<String> beanName,
56+
private RegisteredBean(ConfigurableListableBeanFactory beanFactory, Supplier<String> beanName,
5757
boolean generatedBeanName, Supplier<RootBeanDefinition> mergedBeanDefinition,
5858
@Nullable RegisteredBean parent) {
5959

@@ -71,7 +71,7 @@ private RegisteredBean(ConfigurableBeanFactory beanFactory, Supplier<String> bea
7171
* @param beanName the bean name
7272
* @return a new {@link RegisteredBean} instance
7373
*/
74-
public static RegisteredBean of(ConfigurableBeanFactory beanFactory,
74+
public static RegisteredBean of(ConfigurableListableBeanFactory beanFactory,
7575
String beanName) {
7676

7777
Assert.notNull(beanFactory, "'beanFactory' must not be null");
@@ -149,7 +149,7 @@ public boolean isGeneratedBeanName() {
149149
* Return the bean factory containing the bean.
150150
* @return the bean factory
151151
*/
152-
public ConfigurableBeanFactory getBeanFactory() {
152+
public ConfigurableListableBeanFactory getBeanFactory() {
153153
return this.beanFactory;
154154
}
155155

@@ -172,7 +172,7 @@ public ResolvableType getBeanType() {
172172
/**
173173
* Return the merged bean definition of the bean.
174174
* @return the merged bean definition
175-
* @see ConfigurableBeanFactory#getMergedBeanDefinition(String)
175+
* @see ConfigurableListableBeanFactory#getMergedBeanDefinition(String)
176176
*/
177177
public RootBeanDefinition getMergedBeanDefinition() {
178178
return this.mergedBeanDefinition.get();

0 commit comments

Comments
 (0)