Polish @ComponentScan/@Configuration/@Lazy Javadoc

This commit is contained in:
Chris Beams 2011-10-11 18:51:15 +00:00
parent 1cea52b66b
commit 3920c5a158
3 changed files with 31 additions and 32 deletions

View File

@ -26,23 +26,25 @@ import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.core.type.filter.TypeFilter; import org.springframework.core.type.filter.TypeFilter;
/** /**
* Configures component scanning directives for use with {@link Configuration @Configuration} * Configures component scanning directives for use with @{@link Configuration} classes.
* classes. Provides support parallel with Spring XML's {@code <context:component-scan>} * Provides support parallel with Spring XML's {@code <context:component-scan>} element.
* element.
* *
* <p>One of {@link #basePackageClasses()}, {@link #basePackages()} or its alias {@link #value()} * <p>One of {@link #basePackageClasses()}, {@link #basePackages()} or its alias
* must be specified. * {@link #value()} must be specified.
* *
* <p>Note that the {@code <context:component-scan>} element has an {@code annotation-config} * <p>Note that the {@code <context:component-scan>} element has an
* attribute, however this annotation does not. This is because in almost all cases when * {@code annotation-config} attribute, however this annotation does not. This is because
* using {@code @ComponentScan}, default annotation config processing (e.g. * in almost all cases when using {@code @ComponentScan}, default annotation config
* processing {@code @Autowired} and friends) is assumed. Furthermore, when using * processing (e.g. processing {@code @Autowired} and friends) is assumed. Furthermore,
* {@link AnnotationConfigApplicationContext}, annotation config processors are always * when using {@link AnnotationConfigApplicationContext}, annotation config processors are
* registered, meaning that any attempt to disable them at the {@code @ComponentScan} level * always registered, meaning that any attempt to disable them at the
* would be ignored. * {@code @ComponentScan} level would be ignored.
*
* <p>See @{@link Configuration} Javadoc for usage examples.
* *
* @author Chris Beams * @author Chris Beams
* @since 3.1 * @since 3.1
* @see Configuration
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE) @Target(ElementType.TYPE)

View File

@ -211,8 +211,8 @@ import org.springframework.stereotype.Component;
* } * }
* }</pre> * }</pre>
* *
* See @{@link Profile} and {@link org.springframework.core.env.Environment} Javadoc for * See @{@link Profile} and {@link org.springframework.core.env.Environment Environment}
* further details. * Javadoc for further details.
* *
* <h3>With Spring XML using the {@code @ImportResource} annotation</h3> * <h3>With Spring XML using the {@code @ImportResource} annotation</h3>
* As mentioned above, {@code @Configuration} classes may be declared as regular Spring * As mentioned above, {@code @Configuration} classes may be declared as regular Spring
@ -273,10 +273,8 @@ import org.springframework.stereotype.Component;
* *
* <h2>Testing support for {@code @Configuration} classes</h2> * <h2>Testing support for {@code @Configuration} classes</h2>
* The Spring <em>TestContext framework</em> available in the {@code spring-test} module * The Spring <em>TestContext framework</em> available in the {@code spring-test} module
* provides the * provides the {@code @ContextConfiguration} annotation, which as of Spring 3.1 can
* {@link org.springframework.test.context.ContextConfiguration @ContextConfiguration} * accept an array of {@code @Configuration} {@code Class} objects:
* annotation, which as of Spring 3.1 can accept an array of {@code @Configuration}
* {@code Class} objects:
* <pre class="code"> * <pre class="code">
* &#064;RunWith(SpringJUnit4ClassRunner.class) * &#064;RunWith(SpringJUnit4ClassRunner.class)
* &#064;ContextConfiguration(classes={AppConfig.class, DatabaseConfig.class}) * &#064;ContextConfiguration(classes={AppConfig.class, DatabaseConfig.class})

View File

@ -26,23 +26,22 @@ import java.lang.annotation.Inherited;
/** /**
* Indicates whether a bean is to be lazily initialized. * Indicates whether a bean is to be lazily initialized.
* *
* <p>May be used on any class directly or indirectly annotated with * <p>May be used on any class directly or indirectly annotated with {@link
* {@link org.springframework.stereotype.Component} or on methods annotated with * org.springframework.stereotype.Component @Component} or on methods annotated with
* {@link Bean}. * {@link Bean @Bean}.
* *
* <p>If this annotation is not present on a Component or Bean definition, eager * <p>If this annotation is not present on a {@code @Component} or {@code @Bean} definition,
* initialization will occur. If present and set to {@code true}, the * eager initialization will occur. If present and set to {@code true}, the {@code @Bean} or
* Bean/Component will not be initialized until referenced by another bean or * {@code @Component} will not be initialized until referenced by another bean or explicitly
* explicitly retrieved from the enclosing * retrieved from the enclosing {@link org.springframework.beans.factory.BeanFactory
* {@link org.springframework.beans.factory.BeanFactory}. If present and set to * BeanFactory}. If present and set to {@code false}, the bean will be instantiated on
* {@code false}, the bean will be instantiated on startup by bean factories * startup by bean factories that perform eager initialization of singletons.
* that perform eager initialization of singletons.
* *
* <p>If Lazy is present on a {@link Configuration @Configuration} class, this * <p>If Lazy is present on a {@link Configuration @Configuration} class, this
* indicates that all {@link Bean @Bean} methods within that {@code @Configuration} * indicates that all {@code @Bean} methods within that {@code @Configuration}
* should be lazily initialized. If Lazy is present and false on a Bean method * should be lazily initialized. If {@code @Lazy} is present and false on a {@code @Bean}
* within a Lazy-annotated Configuration class, this indicates overriding the * method within a {@code @Lazy}-annotated {@code @Configuration} class, this indicates
* 'default lazy' behavior and that the bean should be eagerly initialized. * overriding the 'default lazy' behavior and that the bean should be eagerly initialized.
* *
* @author Chris Beams * @author Chris Beams
* @since 3.0 * @since 3.0