Skip to content

Commit 5587262

Browse files
committed
Polishing
1 parent 6dcabd8 commit 5587262

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/FactoryBean.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -39,10 +39,16 @@
3939
*
4040
* <p><b>{@code FactoryBean} is a programmatic contract. Implementations are not
4141
* supposed to rely on annotation-driven injection or other reflective facilities.</b>
42-
* {@link #getObjectType()} {@link #getObject()} invocations may arrive early in
43-
* the bootstrap process, even ahead of any post-processor setup. If you need access
42+
* {@link #getObjectType()} {@link #getObject()} invocations may arrive early in the
43+
* bootstrap process, even ahead of any post-processor setup. If you need access to
4444
* other beans, implement {@link BeanFactoryAware} and obtain them programmatically.
4545
*
46+
* <p><b>The container is only responsible for managing the lifecycle of the FactoryBean
47+
* instance, not the lifecycle of the objects created by the FactoryBean.</b> Therefore,
48+
* a destroy method on an exposed bean object (such as {@link java.io.Closeable#close()}
49+
* will <i>not</i> be called automatically. Instead, a FactoryBean should implement
50+
* {@link DisposableBean} and delegate any such close call to the underlying object.
51+
*
4652
* <p>Finally, FactoryBean objects participate in the containing BeanFactory's
4753
* synchronization of bean creation. There is usually no need for internal
4854
* synchronization other than for purposes of lazy initialization within the
@@ -51,6 +57,7 @@
5157
* @author Rod Johnson
5258
* @author Juergen Hoeller
5359
* @since 08.03.2003
60+
* @param <T> the bean type
5461
* @see org.springframework.beans.factory.BeanFactory
5562
* @see org.springframework.aop.framework.ProxyFactoryBean
5663
* @see org.springframework.jndi.JndiObjectFactoryBean

spring-context/src/main/java/org/springframework/context/index/CandidateComponentsIndex.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -57,6 +57,19 @@ public class CandidateComponentsIndex {
5757
this.index = parseIndex(content);
5858
}
5959

60+
private static MultiValueMap<String, Entry> parseIndex(List<Properties> content) {
61+
MultiValueMap<String, Entry> index = new LinkedMultiValueMap<>();
62+
for (Properties entry : content) {
63+
entry.forEach((type, values) -> {
64+
String[] stereotypes = ((String) values).split(",");
65+
for (String stereotype : stereotypes) {
66+
index.add(stereotype, new Entry((String) type));
67+
}
68+
});
69+
}
70+
return index;
71+
}
72+
6073

6174
/**
6275
* Return the candidate types that are associated with the specified stereotype.
@@ -76,21 +89,11 @@ public Set<String> getCandidateTypes(String basePackage, String stereotype) {
7689
return Collections.emptySet();
7790
}
7891

79-
private static MultiValueMap<String, Entry> parseIndex(List<Properties> content) {
80-
MultiValueMap<String, Entry> index = new LinkedMultiValueMap<>();
81-
for (Properties entry : content) {
82-
entry.forEach((type, values) -> {
83-
String[] stereotypes = ((String) values).split(",");
84-
for (String stereotype : stereotypes) {
85-
index.add(stereotype, new Entry((String) type));
86-
}
87-
});
88-
}
89-
return index;
90-
}
9192

9293
private static class Entry {
94+
9395
private final String type;
96+
9497
private final String packageName;
9598

9699
Entry(String type) {
@@ -106,7 +109,6 @@ public boolean match(String basePackage) {
106109
return this.type.startsWith(basePackage);
107110
}
108111
}
109-
110112
}
111113

112114
}

spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public void testWithComponentAnnotationOnly() {
300300
}
301301

302302
@Test
303-
public void testWithAspectAnnotationOnly() throws Exception {
303+
public void testWithAspectAnnotationOnly() {
304304
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
305305
provider.addIncludeFilter(new AnnotationTypeFilter(Aspect.class));
306306
Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);

spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ public void loadIndexNoSpringComponentsResource() {
9292
}
9393

9494
@Test
95-
public void loadIndexNoEntry() throws IOException {
95+
public void loadIndexNoEntry() {
9696
CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex(
9797
CandidateComponentsTestClassLoader.index(getClass().getClassLoader(),
9898
new ClassPathResource("empty-spring.components", getClass())));
9999
assertThat(index, is(nullValue()));
100100
}
101101

102102
@Test
103-
public void loadIndexWithException() throws IOException {
103+
public void loadIndexWithException() {
104104
final IOException cause = new IOException("test exception");
105105
this.thrown.expect(IllegalStateException.class);
106106
this.thrown.expectMessage("Unable to load indexes");

spring-web/src/main/java/org/springframework/web/cors/DefaultCorsProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -186,7 +186,7 @@ protected String checkOrigin(CorsConfiguration config, @Nullable String requestO
186186
/**
187187
* Check the HTTP method and determine the methods for the response of a
188188
* pre-flight request. The default implementation simply delegates to
189-
* {@link org.springframework.web.cors.CorsConfiguration#checkOrigin(String)}.
189+
* {@link org.springframework.web.cors.CorsConfiguration#checkHttpMethod(HttpMethod)}.
190190
*/
191191
@Nullable
192192
protected List<HttpMethod> checkMethods(CorsConfiguration config, @Nullable HttpMethod requestMethod) {

0 commit comments

Comments
 (0)