Skip to content

Commit 03bda29

Browse files
committed
Revert "AnnotationConfigRegistry exposes registerBean with supplier/qualifiers"
This reverts commit 18f2e6a
1 parent a948681 commit 03bda29

File tree

5 files changed

+18
-297
lines changed

5 files changed

+18
-297
lines changed

spring-context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -197,43 +197,6 @@ public void registerBean(Class<?> annotatedClass, String name, Class<? extends A
197197
doRegisterBean(annotatedClass, null, name, qualifiers);
198198
}
199199

200-
/**
201-
* Register a bean from the given bean class, deriving its metadata from
202-
* class-declared annotations, using the given supplier for obtaining a new
203-
* instance (possibly declared as a lambda expression or method reference).
204-
* @param annotatedClass the class of the bean
205-
* @param instanceSupplier a callback for creating an instance of the bean
206-
* (may be {@code null})
207-
* @param qualifiers specific qualifier annotations to consider,
208-
* in addition to qualifiers at the bean class level
209-
* @since 5.2
210-
*/
211-
@SuppressWarnings("unchecked")
212-
public <T> void registerBean(Class<T> annotatedClass, @Nullable Supplier<T> instanceSupplier,
213-
Class<? extends Annotation>... qualifiers) {
214-
215-
doRegisterBean(annotatedClass, instanceSupplier, null, qualifiers);
216-
}
217-
218-
/**
219-
* Register a bean from the given bean class, deriving its metadata from
220-
* class-declared annotations, using the given supplier for obtaining a new
221-
* instance (possibly declared as a lambda expression or method reference).
222-
* @param annotatedClass the class of the bean
223-
* @param name an explicit name for the bean
224-
* @param instanceSupplier a callback for creating an instance of the bean
225-
* (may be {@code null})
226-
* @param qualifiers specific qualifier annotations to consider,
227-
* in addition to qualifiers at the bean class level
228-
* @since 5.2
229-
*/
230-
@SuppressWarnings("unchecked")
231-
public <T> void registerBean(Class<T> annotatedClass, String name, @Nullable Supplier<T> instanceSupplier,
232-
Class<? extends Annotation>... qualifiers) {
233-
234-
doRegisterBean(annotatedClass, instanceSupplier, name, qualifiers);
235-
}
236-
237200
/**
238201
* Register a bean from the given bean class, deriving its metadata from
239202
* class-declared annotations.

spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java

Lines changed: 7 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2018 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,7 +16,6 @@
1616

1717
package org.springframework.context.annotation;
1818

19-
import java.lang.annotation.Annotation;
2019
import java.util.function.Supplier;
2120

2221
import org.springframework.beans.factory.config.BeanDefinitionCustomizer;
@@ -153,8 +152,7 @@ public void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver
153152
* @see #scan(String...)
154153
* @see #refresh()
155154
*/
156-
@Override
157-
public final void register(Class<?>... annotatedClasses) {
155+
public void register(Class<?>... annotatedClasses) {
158156
Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified");
159157
this.reader.register(annotatedClasses);
160158
}
@@ -167,8 +165,7 @@ public final void register(Class<?>... annotatedClasses) {
167165
* @see #register(Class...)
168166
* @see #refresh()
169167
*/
170-
@Override
171-
public final void scan(String... basePackages) {
168+
public void scan(String... basePackages) {
172169
Assert.notEmpty(basePackages, "At least one base package must be specified");
173170
this.scanner.scan(basePackages);
174171
}
@@ -178,65 +175,6 @@ public final void scan(String... basePackages) {
178175
// Convenient methods for registering individual beans
179176
//---------------------------------------------------------------------
180177

181-
/**
182-
* Register a bean from the given bean class.
183-
* @param annotatedClass the class of the bean
184-
* @since 5.2
185-
*/
186-
public final <T> void registerBean(Class<T> annotatedClass) {
187-
this.reader.doRegisterBean(annotatedClass, null, null, null);
188-
}
189-
190-
/**
191-
* Register a bean from the given bean class, using the given supplier for
192-
* obtaining a new instance (typically declared as a lambda expression or
193-
* method reference).
194-
* @param annotatedClass the class of the bean
195-
* @param supplier a callback for creating an instance of the bean
196-
* @since 5.2
197-
*/
198-
public final <T> void registerBean(Class<T> annotatedClass, Supplier<T> supplier) {
199-
this.reader.doRegisterBean(annotatedClass, supplier, null, null);
200-
}
201-
202-
/**
203-
* Register a bean from the given bean class, deriving its metadata from
204-
* class-declared annotations.
205-
* @param annotatedClass the class of the bean
206-
* @param qualifiers specific qualifier annotations to consider,
207-
* in addition to qualifiers at the bean class level (may be empty).
208-
* These can be actual autowire qualifiers as well as {@link Primary}
209-
* and {@link Lazy}.
210-
* @since 5.2
211-
*/
212-
@Override
213-
@SafeVarargs
214-
@SuppressWarnings("varargs")
215-
public final <T> void registerBean(Class<T> annotatedClass, Class<? extends Annotation>... qualifiers) {
216-
this.reader.doRegisterBean(annotatedClass, null, null, qualifiers);
217-
}
218-
219-
/**
220-
* Register a bean from the given bean class, using the given supplier for
221-
* obtaining a new instance (typically declared as a lambda expression or
222-
* method reference).
223-
* @param annotatedClass the class of the bean
224-
* @param supplier a callback for creating an instance of the bean
225-
* @param qualifiers specific qualifier annotations to consider,
226-
* in addition to qualifiers at the bean class level (may be empty).
227-
* These can be actual autowire qualifiers as well as {@link Primary}
228-
* and {@link Lazy}.
229-
* @since 5.2
230-
*/
231-
@Override
232-
@SafeVarargs
233-
@SuppressWarnings("varargs")
234-
public final <T> void registerBean(
235-
Class<T> annotatedClass, Supplier<T> supplier, Class<? extends Annotation>... qualifiers) {
236-
237-
this.reader.doRegisterBean(annotatedClass, supplier, null, qualifiers);
238-
}
239-
240178
/**
241179
* Register a bean from the given bean class, deriving its metadata from
242180
* class-declared annotations, and optionally providing explicit constructor
@@ -249,7 +187,7 @@ public final <T> void registerBean(
249187
* (may be {@code null} or empty)
250188
* @since 5.0
251189
*/
252-
public final <T> void registerBean(Class<T> annotatedClass, Object... constructorArguments) {
190+
public <T> void registerBean(Class<T> annotatedClass, Object... constructorArguments) {
253191
registerBean(null, annotatedClass, constructorArguments);
254192
}
255193

@@ -265,9 +203,7 @@ public final <T> void registerBean(Class<T> annotatedClass, Object... constructo
265203
* (may be {@code null} or empty)
266204
* @since 5.0
267205
*/
268-
public final <T> void registerBean(
269-
@Nullable String beanName, Class<T> annotatedClass, Object... constructorArguments) {
270-
206+
public <T> void registerBean(@Nullable String beanName, Class<T> annotatedClass, Object... constructorArguments) {
271207
this.reader.doRegisterBean(annotatedClass, null, beanName, null,
272208
bd -> {
273209
for (Object arg : constructorArguments) {
@@ -277,8 +213,8 @@ public final <T> void registerBean(
277213
}
278214

279215
@Override
280-
public final <T> void registerBean(@Nullable String beanName, Class<T> beanClass,
281-
@Nullable Supplier<T> supplier, BeanDefinitionCustomizer... customizers) {
216+
public <T> void registerBean(@Nullable String beanName, Class<T> beanClass, @Nullable Supplier<T> supplier,
217+
BeanDefinitionCustomizer... customizers) {
282218

283219
this.reader.doRegisterBean(beanClass, supplier, beanName, null, customizers);
284220
}
Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 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,9 +16,6 @@
1616

1717
package org.springframework.context.annotation;
1818

19-
import java.lang.annotation.Annotation;
20-
import java.util.function.Supplier;
21-
2219
/**
2320
* Common interface for annotation config application contexts,
2421
* defining {@link #register} and {@link #scan} methods.
@@ -43,32 +40,4 @@ public interface AnnotationConfigRegistry {
4340
*/
4441
void scan(String... basePackages);
4542

46-
/**
47-
* Register a bean from the given bean class, deriving its metadata from
48-
* class-declared annotations.
49-
* @param annotatedClass the class of the bean
50-
* @param qualifiers specific qualifier annotations to consider,
51-
* in addition to qualifiers at the bean class level (may be empty).
52-
* These can be actual autowire qualifiers as well as {@link Primary}
53-
* and {@link Lazy}.
54-
* @since 5.2
55-
*/
56-
@SuppressWarnings("unchecked")
57-
<T> void registerBean(Class<T> annotatedClass, Class<? extends Annotation>... qualifiers);
58-
59-
/**
60-
* Register a bean from the given bean class, using the given supplier for
61-
* obtaining a new instance (typically declared as a lambda expression or
62-
* method reference).
63-
* @param annotatedClass the class of the bean
64-
* @param supplier a callback for creating an instance of the bean
65-
* @param qualifiers specific qualifier annotations to consider,
66-
* in addition to qualifiers at the bean class level (may be empty).
67-
* These can be actual autowire qualifiers as well as {@link Primary}
68-
* and {@link Lazy}.
69-
* @since 5.2
70-
*/
71-
@SuppressWarnings("unchecked")
72-
<T> void registerBean(Class<T> annotatedClass, Supplier<T> supplier, Class<? extends Annotation>... qualifiers);
73-
7443
}

0 commit comments

Comments
 (0)