|
46 | 46 | *
|
47 | 47 | * <h3>Via {@code AnnotationConfigApplicationContext}</h3>
|
48 | 48 | *
|
49 |
| - * {@code @Configuration} classes are typically bootstrapped using either |
| 49 | + * <p>{@code @Configuration} classes are typically bootstrapped using either |
50 | 50 | * {@link AnnotationConfigApplicationContext} or its web-capable variant,
|
51 | 51 | * {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext
|
52 | 52 | * AnnotationConfigWebApplicationContext}. A simple example with the former follows:
|
|
59 | 59 | * // use myBean ...
|
60 | 60 | * </pre>
|
61 | 61 | *
|
62 |
| - * See {@link AnnotationConfigApplicationContext} Javadoc for further details and see |
| 62 | + * <p>See the {@link AnnotationConfigApplicationContext} javadocs for further details, and see |
63 | 63 | * {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext
|
64 |
| - * AnnotationConfigWebApplicationContext} for {@code web.xml} configuration instructions. |
| 64 | + * AnnotationConfigWebApplicationContext} for web configuration instructions in a |
| 65 | + * {@code Servlet} container. |
65 | 66 | *
|
66 | 67 | * <h3>Via Spring {@code <beans>} XML</h3>
|
67 | 68 | *
|
68 | 69 | * <p>As an alternative to registering {@code @Configuration} classes directly against an
|
69 | 70 | * {@code AnnotationConfigApplicationContext}, {@code @Configuration} classes may be
|
70 | 71 | * declared as normal {@code <bean>} definitions within Spring XML files:
|
| 72 | + * |
71 | 73 | * <pre class="code">
|
72 | 74 | * <beans>
|
73 | 75 | * <context:annotation-config/>
|
74 | 76 | * <bean class="com.acme.AppConfig"/>
|
75 | 77 | * </beans>
|
76 | 78 | * </pre>
|
77 | 79 | *
|
78 |
| - * In the example above, {@code <context:annotation-config/>} is required in order to |
| 80 | + * <p>In the example above, {@code <context:annotation-config/>} is required in order to |
79 | 81 | * enable {@link ConfigurationClassPostProcessor} and other annotation-related
|
80 | 82 | * post processors that facilitate handling {@code @Configuration} classes.
|
81 | 83 | *
|
|
113 | 115 | * // various @Bean definitions ...
|
114 | 116 | * }</pre>
|
115 | 117 | *
|
116 |
| - * See the {@link ComponentScan @ComponentScan} javadoc for details. |
| 118 | + * <p>See the {@link ComponentScan @ComponentScan} javadocs for details. |
117 | 119 | *
|
118 | 120 | * <h2>Working with externalized values</h2>
|
119 | 121 | *
|
120 | 122 | * <h3>Using the {@code Environment} API</h3>
|
121 | 123 | *
|
122 |
| - * Externalized values may be looked up by injecting the Spring |
| 124 | + * <p>Externalized values may be looked up by injecting the Spring |
123 | 125 | * {@link org.springframework.core.env.Environment} into a {@code @Configuration}
|
124 | 126 | * class — for example, using the {@code @Autowired} annotation:
|
125 | 127 | *
|
|
137 | 139 | * }
|
138 | 140 | * }</pre>
|
139 | 141 | *
|
140 |
| - * Properties resolved through the {@code Environment} reside in one or more "property |
| 142 | + * <p>Properties resolved through the {@code Environment} reside in one or more "property |
141 | 143 | * source" objects, and {@code @Configuration} classes may contribute property sources to
|
142 | 144 | * the {@code Environment} object using the {@link PropertySource @PropertySource}
|
143 | 145 | * annotation:
|
|
155 | 157 | * }
|
156 | 158 | * }</pre>
|
157 | 159 | *
|
158 |
| - * See {@link org.springframework.core.env.Environment Environment} |
159 |
| - * and {@link PropertySource @PropertySource} Javadoc for further details. |
| 160 | + * <p>See the {@link org.springframework.core.env.Environment Environment} |
| 161 | + * and {@link PropertySource @PropertySource} javadocs for further details. |
160 | 162 | *
|
161 | 163 | * <h3>Using the {@code @Value} annotation</h3>
|
162 | 164 | *
|
163 |
| - * Externalized values may be 'wired into' {@code @Configuration} classes using |
164 |
| - * the {@link Value @Value} annotation: |
| 165 | + * <p>Externalized values may be injected {@code @Configuration} classes using the |
| 166 | + * {@link Value @Value} annotation: |
165 | 167 | *
|
166 | 168 | * <pre class="code">
|
167 | 169 | * @Configuration
|
|
176 | 178 | * }
|
177 | 179 | * }</pre>
|
178 | 180 | *
|
179 |
| - * This approach is most useful when using Spring's |
| 181 | + * <p>This approach is most useful when using Spring's |
180 | 182 | * {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer
|
181 | 183 | * PropertySourcesPlaceholderConfigurer}, usually enabled via XML with
|
182 | 184 | * {@code <context:property-placeholder/>}. See the section below on composing
|
183 | 185 | * {@code @Configuration} classes with Spring XML using {@code @ImportResource},
|
184 |
| - * see {@link Value @Value} Javadoc, and see {@link Bean @Bean} Javadoc for details |
185 |
| - * on working with {@code BeanFactoryPostProcessor} types such as |
| 186 | + * see the {@link Value @Value} javadocs, and see the {@link Bean @Bean} javadocs for |
| 187 | + * details on working with {@code BeanFactoryPostProcessor} types such as |
186 | 188 | * {@code PropertySourcesPlaceholderConfigurer}.
|
187 | 189 | *
|
188 | 190 | * <h2>Composing {@code @Configuration} classes</h2>
|
|
221 | 223 | * }
|
222 | 224 | * }</pre>
|
223 | 225 | *
|
224 |
| - * Now both {@code AppConfig} and the imported {@code DatabaseConfig} can be bootstrapped |
| 226 | + * <p>Now both {@code AppConfig} and the imported {@code DatabaseConfig} can be bootstrapped |
225 | 227 | * by registering only {@code AppConfig} against the Spring context:
|
226 | 228 | *
|
227 | 229 | * <pre class="code">
|
228 | 230 | * new AnnotationConfigApplicationContext(AppConfig.class);</pre>
|
229 | 231 | *
|
230 | 232 | * <h3>With the {@code @Profile} annotation</h3>
|
231 | 233 | *
|
232 |
| - * {@code @Configuration} classes may be marked with the {@link Profile @Profile} annotation to |
| 234 | + * <p>{@code @Configuration} classes may be marked with the {@link Profile @Profile} annotation to |
233 | 235 | * indicate they should be processed only if a given profile or profiles are <em>active</em>:
|
234 | 236 | *
|
235 | 237 | * <pre class="code">
|
|
253 | 255 | * }
|
254 | 256 | * }</pre>
|
255 | 257 | *
|
256 |
| - * Alternatively, you may also declare profile conditions at the {@code @Bean} method level, |
257 |
| - * e.g. for alternative bean variants within the same configuration class: |
| 258 | + * <p>Alternatively, you may also declare profile conditions at the {@code @Bean} method level |
| 259 | + * — for example, for alternative bean variants within the same configuration class: |
258 | 260 | *
|
259 | 261 | * <pre class="code">
|
260 | 262 | * @Configuration
|
|
269 | 271 | * public DataSource productionDatabase() { ... }
|
270 | 272 | * }</pre>
|
271 | 273 | *
|
272 |
| - * See the {@link Profile @Profile} and {@link org.springframework.core.env.Environment} |
| 274 | + * <p>See the {@link Profile @Profile} and {@link org.springframework.core.env.Environment} |
273 | 275 | * javadocs for further details.
|
274 | 276 | *
|
275 | 277 | * <h3>With Spring XML using the {@code @ImportResource} annotation</h3>
|
276 | 278 | *
|
277 |
| - * As mentioned above, {@code @Configuration} classes may be declared as regular Spring |
| 279 | + * <p>As mentioned above, {@code @Configuration} classes may be declared as regular Spring |
278 | 280 | * {@code <bean>} definitions within Spring XML files. It is also possible to
|
279 | 281 | * import Spring XML configuration files into {@code @Configuration} classes using
|
280 | 282 | * the {@link ImportResource @ImportResource} annotation. Bean definitions imported from
|
|
296 | 298 | *
|
297 | 299 | * <h3>With nested {@code @Configuration} classes</h3>
|
298 | 300 | *
|
299 |
| - * {@code @Configuration} classes may be nested within one another as follows: |
| 301 | + * <p>{@code @Configuration} classes may be nested within one another as follows: |
300 | 302 | *
|
301 | 303 | * <pre class="code">
|
302 | 304 | * @Configuration
|
|
318 | 320 | * }
|
319 | 321 | * }</pre>
|
320 | 322 | *
|
321 |
| - * When bootstrapping such an arrangement, only {@code AppConfig} need be registered |
| 323 | + * <p>When bootstrapping such an arrangement, only {@code AppConfig} need be registered |
322 | 324 | * against the application context. By virtue of being a nested {@code @Configuration}
|
323 | 325 | * class, {@code DatabaseConfig} <em>will be registered automatically</em>. This avoids
|
324 | 326 | * the need to use an {@code @Import} annotation when the relationship between
|
325 |
| - * {@code AppConfig} {@code DatabaseConfig} is already implicitly clear. |
| 327 | + * {@code AppConfig} and {@code DatabaseConfig} is already implicitly clear. |
326 | 328 | *
|
327 | 329 | * <p>Note also that nested {@code @Configuration} classes can be used to good effect
|
328 | 330 | * with the {@code @Profile} annotation to provide two options of the same bean to the
|
|
338 | 340 | *
|
339 | 341 | * <h2>Testing support for {@code @Configuration} classes</h2>
|
340 | 342 | *
|
341 |
| - * The Spring <em>TestContext framework</em> available in the {@code spring-test} module |
| 343 | + * <p>The Spring <em>TestContext framework</em> available in the {@code spring-test} module |
342 | 344 | * provides the {@code @ContextConfiguration} annotation which can accept an array of
|
343 | 345 | * {@code @Configuration} {@code Class} objects:
|
344 | 346 | *
|
|
363 | 365 | *
|
364 | 366 | * <h2>Enabling built-in Spring features using {@code @Enable} annotations</h2>
|
365 | 367 | *
|
366 |
| - * Spring features such as asynchronous method execution, scheduled task execution, |
| 368 | + * <p>Spring features such as asynchronous method execution, scheduled task execution, |
367 | 369 | * annotation driven transaction management, and even Spring MVC can be enabled and
|
368 |
| - * configured from {@code @Configuration} |
369 |
| - * classes using their respective "{@code @Enable}" annotations. See |
| 370 | + * configured from {@code @Configuration} classes using their respective "{@code @Enable}" |
| 371 | + * annotations. See |
370 | 372 | * {@link org.springframework.scheduling.annotation.EnableAsync @EnableAsync},
|
371 | 373 | * {@link org.springframework.scheduling.annotation.EnableScheduling @EnableScheduling},
|
372 | 374 | * {@link org.springframework.transaction.annotation.EnableTransactionManagement @EnableTransactionManagement},
|
|
409 | 411 | public @interface Configuration {
|
410 | 412 |
|
411 | 413 | /**
|
412 |
| - * Explicitly specify the name of the Spring bean definition associated |
413 |
| - * with this Configuration class. If left unspecified (the common case), |
414 |
| - * a bean name will be automatically generated. |
415 |
| - * <p>The custom name applies only if the Configuration class is picked up via |
416 |
| - * component scanning or supplied directly to a {@link AnnotationConfigApplicationContext}. |
417 |
| - * If the Configuration class is registered as a traditional XML bean definition, |
418 |
| - * the name/id of the bean element will take precedence. |
419 |
| - * @return the suggested component name, if any (or empty String otherwise) |
| 414 | + * Explicitly specify the name of the Spring bean definition associated with the |
| 415 | + * {@code @Configuration} class. If left unspecified (the common case), a bean |
| 416 | + * name will be automatically generated. |
| 417 | + * <p>The custom name applies only if the {@code @Configuration} class is picked |
| 418 | + * up via component scanning or supplied directly to an |
| 419 | + * {@link AnnotationConfigApplicationContext}. If the {@code @Configuration} class |
| 420 | + * is registered as a traditional XML bean definition, the name/id of the bean |
| 421 | + * element will take precedence. |
| 422 | + * @return the explicit component name, if any (or empty String otherwise) |
420 | 423 | * @see org.springframework.beans.factory.support.DefaultBeanNameGenerator
|
421 | 424 | */
|
422 | 425 | @AliasFor(annotation = Component.class)
|
|
0 commit comments