Deprecate RootBeanDefinition(ResolvableType) constructor

Closes gh-30704
This commit is contained in:
Juergen Hoeller 2023-06-21 09:48:00 +02:00
parent 20bbebb299
commit 049a024dea
4 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -125,7 +125,8 @@ public final class BeanDefinitionBuilder {
* @since 5.3.9
*/
public static <T> BeanDefinitionBuilder rootBeanDefinition(ResolvableType beanType, Supplier<T> instanceSupplier) {
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanType);
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setTargetType(beanType);
beanDefinition.setInstanceSupplier(instanceSupplier);
return new BeanDefinitionBuilder(beanDefinition);
}

View File

@ -161,7 +161,9 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @param beanType the type of bean to instantiate
* @since 6.0
* @see #setTargetType(ResolvableType)
* @deprecated as of 6.0.11, in favor of an extra {@link #setTargetType(ResolvableType)} call
*/
@Deprecated(since = "6.0.11")
public RootBeanDefinition(@Nullable ResolvableType beanType) {
setTargetType(beanType);
}

View File

@ -170,8 +170,9 @@ class BeanDefinitionMethodGeneratorTests {
@Test
void generateBeanDefinitionMethodWhenHasGenericsGeneratesMethod() {
RegisteredBean registeredBean = registerBean(new RootBeanDefinition(
ResolvableType.forClassWithGenerics(GenericBean.class, Integer.class)));
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setTargetType(ResolvableType.forClassWithGenerics(GenericBean.class, Integer.class));
RegisteredBean registeredBean = registerBean(beanDefinition);
BeanDefinitionMethodGenerator generator = new BeanDefinitionMethodGenerator(
this.methodGeneratorFactory, registeredBean, null,
Collections.emptyList());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -172,8 +172,9 @@ class DefaultBeanRegistrationCodeFragmentsTests {
}
private RegisteredBean registerTestBean(ResolvableType beanType) {
this.beanFactory.registerBeanDefinition("testBean",
new RootBeanDefinition(beanType));
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setTargetType(beanType);
this.beanFactory.registerBeanDefinition("testBean", beanDefinition);
return RegisteredBean.of(this.beanFactory, "testBean");
}