|
23 | 23 | import java.lang.annotation.Target; |
24 | 24 |
|
25 | 25 | import org.springframework.boot.SpringBootConfiguration; |
| 26 | +import org.springframework.context.annotation.Bean; |
26 | 27 | import org.springframework.context.annotation.Configuration; |
27 | 28 | import org.springframework.core.annotation.AliasFor; |
28 | 29 |
|
|
51 | 52 | @AliasFor(annotation = Configuration.class) |
52 | 53 | String value() default ""; |
53 | 54 |
|
| 55 | + /** |
| 56 | + * Specify whether {@link Bean @Bean} methods should get proxied in order to enforce |
| 57 | + * bean lifecycle behavior, e.g. to return shared singleton bean instances even in |
| 58 | + * case of direct {@code @Bean} method calls in user code. This feature requires |
| 59 | + * method interception, implemented through a runtime-generated CGLIB subclass which |
| 60 | + * comes with limitations such as the configuration class and its methods not being |
| 61 | + * allowed to declare {@code final}. |
| 62 | + * <p> |
| 63 | + * The default is {@code true}, allowing for 'inter-bean references' within the |
| 64 | + * configuration class as well as for external calls to this configuration's |
| 65 | + * {@code @Bean} methods, e.g. from another configuration class. If this is not needed |
| 66 | + * since each of this particular configuration's {@code @Bean} methods is |
| 67 | + * self-contained and designed as a plain factory method for container use, switch |
| 68 | + * this flag to {@code false} in order to avoid CGLIB subclass processing. |
| 69 | + * <p> |
| 70 | + * Turning off bean method interception effectively processes {@code @Bean} methods |
| 71 | + * individually like when declared on non-{@code @Configuration} classes, a.k.a. |
| 72 | + * "@Bean Lite Mode" (see {@link Bean @Bean's javadoc}). It is therefore behaviorally |
| 73 | + * equivalent to removing the {@code @Configuration} stereotype. |
| 74 | + * @since 2.2.1 |
| 75 | + * @return whether to proxy {@code @Bean} methods |
| 76 | + */ |
| 77 | + @AliasFor(annotation = Configuration.class) |
| 78 | + boolean proxyBeanMethods() default true; |
| 79 | + |
54 | 80 | } |
0 commit comments