Skip to content

Commit 28dbcb2

Browse files
committed
Improve FactoryBean Javadoc
1 parent c85050e commit 28dbcb2

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 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,9 +39,9 @@
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 the
43-
* bootstrap process, even ahead of any post-processor setup. If you need access to
44-
* other beans, implement {@link BeanFactoryAware} and obtain them programmatically.
42+
* Invocations of {@link #getObjectType()} and {@link #getObject()} may arrive early
43+
* in the bootstrap process, even ahead of any post-processor setup. If you need access
44+
* to other beans, implement {@link BeanFactoryAware} and obtain them programmatically.
4545
*
4646
* <p><b>The container is only responsible for managing the lifecycle of the FactoryBean
4747
* instance, not the lifecycle of the objects created by the FactoryBean.</b> Therefore,
@@ -50,7 +50,7 @@
5050
* {@link DisposableBean} and delegate any such close call to the underlying object.
5151
*
5252
* <p>Finally, FactoryBean objects participate in the containing BeanFactory's
53-
* synchronization of bean creation. There is usually no need for internal
53+
* synchronization of bean creation. Thus, there is usually no need for internal
5454
* synchronization other than for purposes of lazy initialization within the
5555
* FactoryBean itself (or the like).
5656
*
@@ -68,7 +68,7 @@ public interface FactoryBean<T> {
6868
* The name of an attribute that can be
6969
* {@link org.springframework.core.AttributeAccessor#setAttribute set} on a
7070
* {@link org.springframework.beans.factory.config.BeanDefinition} so that
71-
* factory beans can signal their object type when it can't be deduced from
71+
* factory beans can signal their object type when it cannot be deduced from
7272
* the factory bean class.
7373
* @since 5.2
7474
*/
@@ -79,15 +79,15 @@ public interface FactoryBean<T> {
7979
* Return an instance (possibly shared or independent) of the object
8080
* managed by this factory.
8181
* <p>As with a {@link BeanFactory}, this allows support for both the
82-
* Singleton and Prototype design pattern.
82+
* Singleton and Prototype design patterns.
8383
* <p>If this FactoryBean is not fully initialized yet at the time of
8484
* the call (for example because it is involved in a circular reference),
8585
* throw a corresponding {@link FactoryBeanNotInitializedException}.
86-
* <p>As of Spring 2.0, FactoryBeans are allowed to return {@code null}
87-
* objects. The factory will consider this as normal value to be used; it
88-
* will not throw a FactoryBeanNotInitializedException in this case anymore.
86+
* <p>FactoryBeans are allowed to return {@code null} objects. The bean
87+
* factory will consider this as a normal value to be used and will not throw
88+
* a {@code FactoryBeanNotInitializedException} in this case. However,
8989
* FactoryBean implementations are encouraged to throw
90-
* FactoryBeanNotInitializedException themselves now, as appropriate.
90+
* {@code FactoryBeanNotInitializedException} themselves, as appropriate.
9191
* @return an instance of the bean (can be {@code null})
9292
* @throws Exception in case of creation errors
9393
* @see FactoryBeanNotInitializedException
@@ -100,7 +100,7 @@ public interface FactoryBean<T> {
100100
* or {@code null} if not known in advance.
101101
* <p>This allows one to check for specific types of beans without
102102
* instantiating objects, for example on autowiring.
103-
* <p>In the case of implementations that are creating a singleton object,
103+
* <p>In the case of implementations that create a singleton object,
104104
* this method should try to avoid singleton creation as far as possible;
105105
* it should rather estimate the type in advance.
106106
* For prototypes, returning a meaningful type here is advisable too.
@@ -121,8 +121,8 @@ public interface FactoryBean<T> {
121121
* Is the object managed by this factory a singleton? That is,
122122
* will {@link #getObject()} always return the same object
123123
* (a reference that can be cached)?
124-
* <p><b>NOTE:</b> If a FactoryBean indicates to hold a singleton object,
125-
* the object returned from {@code getObject()} might get cached
124+
* <p><b>NOTE:</b> If a FactoryBean indicates that it holds a singleton
125+
* object, the object returned from {@code getObject()} might get cached
126126
* by the owning BeanFactory. Hence, do not return {@code true}
127127
* unless the FactoryBean always exposes the same reference.
128128
* <p>The singleton status of the FactoryBean itself will generally

0 commit comments

Comments
 (0)