32
32
import org .springframework .beans .factory .BeanNameAware ;
33
33
import org .springframework .beans .factory .DisposableBean ;
34
34
import org .springframework .beans .factory .InitializingBean ;
35
+ import org .springframework .lang .NonNull ;
36
+ import org .springframework .lang .Nullable ;
35
37
import org .springframework .util .Assert ;
36
38
import org .springframework .util .StringUtils ;
37
39
41
43
/**
42
44
* The {@link GemfireBeanFactoryLocator} class stores a reference to the Spring
43
45
* {@link org.springframework.context.ApplicationContext} / {@link BeanFactory} needed to auto-wire
44
- * user application GemFire objects implementing the {@link org.apache.geode.cache.Declarable} interface
45
- * and defined in GemFire 's native configuration format (e.g. {@literal cache.xml}.
46
+ * user application Apache Geode objects implementing the {@link org.apache.geode.cache.Declarable} interface
47
+ * and defined in Apache Geode 's native configuration format (e.g. {@literal cache.xml}.
46
48
*
47
- * In most cases, a developer does not need to use this class directly as it is registered by the
48
- * {@link org.springframework.data.gemfire.CacheFactoryBean} when the {@literal useBeanFactoryLocator} property
49
- * is set, and used internally by bothe the {@link WiringDeclarableSupport} and {@link LazyWiringDeclarableSupport}
50
- * SDG classes.
49
+ * In most cases, a developer does not need to use this class directly as it is registered by
50
+ * the {@link org.springframework.data.gemfire.CacheFactoryBean} or {@link org.springframework.data.gemfire.LocatorFactoryBean}
51
+ * when the {@literal useBeanFactoryLocator} property is set, and used internally by both
52
+ * the {@link WiringDeclarableSupport} and {@link LazyWiringDeclarableSupport} SDG classes.
51
53
*
52
54
* @author Costin Leau
53
55
* @author John Blum
54
- * @see LazyWiringDeclarableSupport
55
- * @see WiringDeclarableSupport
56
+ * @see org.springframework.beans.factory.BeanFactory
57
+ * @see org.springframework.beans.factory.BeanFactoryAware
58
+ * @see org.springframework.beans.factory.BeanNameAware
59
+ * @see org.springframework.beans.factory.DisposableBean
60
+ * @see org.springframework.beans.factory.InitializingBean
61
+ * @see org.springframework.data.gemfire.support.LazyWiringDeclarableSupport
62
+ * @see org.springframework.data.gemfire.support.WiringDeclarableSupport
56
63
*/
57
- @ SuppressWarnings ("all" )
58
64
public class GemfireBeanFactoryLocator implements BeanFactoryAware , BeanNameAware , DisposableBean , InitializingBean {
59
65
60
66
// Bean alias/name <-> BeanFactory mapping
@@ -69,21 +75,23 @@ public class GemfireBeanFactoryLocator implements BeanFactoryAware, BeanNameAwar
69
75
private String associatedBeanName ;
70
76
71
77
/**
72
- * Cleans up all {@link BeanFactory} references tracked by this locator.
78
+ * Cleans up all {@link BeanFactory} references tracked by this {@literal locator} .
73
79
*/
74
80
public static void clear () {
75
81
BEAN_FACTORIES .clear ();
76
82
}
77
83
78
84
/**
79
- * Factory method to construct a new, initialized instance of {@link GemfireBeanFactoryLocator}.
85
+ * Factory method used to construct a new instance of {@link GemfireBeanFactoryLocator}.
86
+ *
87
+ * The {@link #afterPropertiesSet()} will be called after construction to initialize this {@literal locator}.
80
88
*
81
89
* @return a new, initialized instance of the {@link GemfireBeanFactoryLocator}.
82
- * @see GemfireBeanFactoryLocator
83
- * @see # GemfireBeanFactoryLocator()
90
+ * @see org.springframework.data.gemfire.support. GemfireBeanFactoryLocator
91
+ * @see GemfireBeanFactoryLocator()
84
92
* @see #afterPropertiesSet()
85
93
*/
86
- public static GemfireBeanFactoryLocator newBeanFactoryLocator () {
94
+ public static @ NonNull GemfireBeanFactoryLocator newBeanFactoryLocator () {
87
95
88
96
GemfireBeanFactoryLocator beanFactoryLocator = new GemfireBeanFactoryLocator ();
89
97
@@ -93,22 +101,25 @@ public static GemfireBeanFactoryLocator newBeanFactoryLocator() {
93
101
}
94
102
95
103
/**
96
- * Factory method to construct a new, initialized instance of {@link GemfireBeanFactoryLocator} with the given
97
- * default Spring {@link BeanFactory} and associated Spring bean name.
104
+ * Factory method used to construct a new instance of {@link GemfireBeanFactoryLocator} initialized with
105
+ * the given, default Spring {@link BeanFactory} and associated Spring {@link String bean name}.
106
+ *
107
+ * The {@link #afterPropertiesSet()} will be called after construction to initialize this {@literal locator}.
98
108
*
99
- * @param beanFactory reference to the {@link BeanFactory} used to resolve Spring bean references.
100
- * @param associatedBeanName {@link String} contain the name of the Spring bean associated with
109
+ * @param beanFactory reference to the Spring {@link BeanFactory} used to resolve Spring bean references.
110
+ * @param associatedBeanName {@link String} containing the {@literal name} of the Spring bean associated with
101
111
* the Spring {@link BeanFactory}.
102
- * @return a new, initialized instance of {@link GemfireBeanFactoryLocator} with the given default
103
- * Spring {@link BeanFactory} and associated Spring bean name.
112
+ * @return a new {@link GemfireBeanFactoryLocator} initialized with the given, default Spring {@link BeanFactory}
113
+ * and associated Spring {@link String bean name}.
114
+ * @see org.springframework.data.gemfire.support.GemfireBeanFactoryLocator
104
115
* @see org.springframework.beans.factory.BeanFactory
105
- * @see GemfireBeanFactoryLocator
106
- * @see #GemfireBeanFactoryLocator()
116
+ * @see GemfireBeanFactoryLocator()
107
117
* @see #setBeanFactory(BeanFactory)
108
118
* @see #setBeanName(String)
109
119
* @see #afterPropertiesSet()
110
120
*/
111
- public static GemfireBeanFactoryLocator newBeanFactoryLocator (BeanFactory beanFactory , String associatedBeanName ) {
121
+ public static @ NonNull GemfireBeanFactoryLocator newBeanFactoryLocator (BeanFactory beanFactory ,
122
+ String associatedBeanName ) {
112
123
113
124
Assert .isTrue (beanFactory == null || StringUtils .hasText (associatedBeanName ),
114
125
"associatedBeanName must be specified when BeanFactory is not null" );
@@ -123,15 +134,15 @@ public static GemfireBeanFactoryLocator newBeanFactoryLocator(BeanFactory beanFa
123
134
}
124
135
125
136
/**
126
- * Resolves the {@link BeanFactory} mapped to the given {@code beanFactoryKey}.
137
+ * Resolves the {@link BeanFactory} mapped to the given {@link String beanFactoryKey}.
127
138
*
128
- * @param beanFactoryKey {@link String} value containing the key used to lookup the {@link BeanFactory}.
139
+ * @param beanFactoryKey {@link String} containing a key used to lookup the {@link BeanFactory}.
129
140
* @return the {@link BeanFactory} mapped to the given key.
130
141
* @throws IllegalArgumentException if a Spring {@link BeanFactory} could not be found
131
- * for the given {@code beanFactoryKey}.
142
+ * for the given {@link String beanFactoryKey}.
132
143
* @see org.springframework.beans.factory.BeanFactory
133
144
*/
134
- protected static BeanFactory resolveBeanFactory (String beanFactoryKey ) {
145
+ protected static @ Nullable BeanFactory resolveBeanFactory (@ NonNull String beanFactoryKey ) {
135
146
136
147
BeanFactory beanFactory = BEAN_FACTORIES .get (beanFactoryKey );
137
148
@@ -142,18 +153,18 @@ protected static BeanFactory resolveBeanFactory(String beanFactoryKey) {
142
153
}
143
154
144
155
/**
145
- * Resolves a single Spring {@link BeanFactory} from the mapping of registered bean factories .
156
+ * Resolves a single Spring {@link BeanFactory} from the mapping of registered {@link BeanFactory BeanFactories} .
146
157
*
147
158
* This class method is synchronized because it contains a "compound action", even though separate actions
148
159
* are performed on a {@link ConcurrentMap}, the actions are not independent and therefore must operate
149
160
* atomically.
150
161
*
151
162
* @return a single Spring {@link BeanFactory} from the registry.
152
- * @throws IllegalStateException if the registry contains more than 1, or no
153
- * Spring {@link BeanFactory bean factories }.
163
+ * @throws IllegalStateException if the registry contains more than 1 registered Spring {@link BeanFactory},
164
+ * or no Spring {@link BeanFactory BeanFactories }.
154
165
* @see org.springframework.beans.factory.BeanFactory
155
166
*/
156
- protected static synchronized BeanFactory resolveSingleBeanFactory () {
167
+ protected static synchronized @ Nullable BeanFactory resolveSingleBeanFactory () {
157
168
158
169
if (!BEAN_FACTORIES .isEmpty ()) {
159
170
@@ -173,7 +184,7 @@ protected static synchronized BeanFactory resolveSingleBeanFactory() {
173
184
174
185
Assert .state (allTheSameBeanFactory ,
175
186
String .format ("BeanFactory key must be specified when more than one BeanFactory %s is registered" ,
176
- new TreeSet (BEAN_FACTORIES .keySet ()). toString ( )));
187
+ new TreeSet <> (BEAN_FACTORIES .keySet ())));
177
188
178
189
return BEAN_FACTORIES .values ().iterator ().next ();
179
190
}
@@ -218,9 +229,6 @@ protected static synchronized boolean unregisterAliases(Set<String> names) {
218
229
return BEAN_FACTORIES .keySet ().removeAll (names );
219
230
}
220
231
221
- /**
222
- * @inheritDoc
223
- */
224
232
@ Override
225
233
public void afterPropertiesSet () {
226
234
@@ -257,9 +265,6 @@ Set<String> resolveAndInitializeBeanNamesWithAliases(BeanFactory beanFactory) {
257
265
return this .associatedBeanNameWithAliases ;
258
266
}
259
267
260
- /**
261
- * @inheritDoc
262
- */
263
268
@ Override
264
269
public void destroy () {
265
270
unregisterAliases (getAssociatedBeanNameWithAliases ());
@@ -379,7 +384,7 @@ protected static class BeanFactoryReference {
379
384
* @param beanFactory {@link BeanFactory} reference to store.
380
385
* @return a new instance of {@link BeanFactoryReference} initialized with the given {@link BeanFactory}.
381
386
* @see org.springframework.beans.factory.BeanFactory
382
- * @see # GemfireBeanFactoryLocator.BeanFactoryReference(BeanFactory)
387
+ * @see GemfireBeanFactoryLocator.BeanFactoryReference(BeanFactory)
383
388
*/
384
389
protected static BeanFactoryReference newBeanFactoryReference (BeanFactory beanFactory ) {
385
390
return new BeanFactoryReference (beanFactory );
0 commit comments