Skip to content

Commit

Permalink
Deprecate RootBeanDefinition(ResolvableType) constructor
Browse files Browse the repository at this point in the history
Closes gh-30704
  • Loading branch information
jhoeller committed Jun 21, 2023
1 parent 20bbebb commit 049a024
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
@@ -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.
Expand Down Expand Up @@ -125,7 +125,8 @@ public static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass, @Null
* @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);
}
Expand Down
Expand Up @@ -161,7 +161,9 @@ public RootBeanDefinition(@Nullable Class<?> beanClass) {
* @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);
}
Expand Down
Expand Up @@ -170,8 +170,9 @@ void generateBeanDefinitionMethodWhenHasNestedInnerClassTargetMethodGeneratesMet

@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());
Expand Down
@@ -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.
Expand Down Expand Up @@ -172,8 +172,9 @@ private RegisteredBean registerTestBean(Class<?> beanType) {
}

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");
}

Expand Down

0 comments on commit 049a024

Please sign in to comment.