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

View File

@ -211,8 +211,8 @@ import org.springframework.stereotype.Component;
* }
* }</pre>
*
* See @{@link Profile} and {@link org.springframework.core.env.Environment} Javadoc for
* further details.
* See @{@link Profile} and {@link org.springframework.core.env.Environment Environment}
* Javadoc for further details.
*
* <h3>With Spring XML using the {@code @ImportResource} annotation</h3>
* 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>
* The Spring <em>TestContext framework</em> available in the {@code spring-test} module
* provides the
* {@link org.springframework.test.context.ContextConfiguration @ContextConfiguration}
* annotation, which as of Spring 3.1 can accept an array of {@code @Configuration}
* {@code Class} objects:
* provides the {@code @ContextConfiguration} annotation, which as of Spring 3.1 can
* accept an array of {@code @Configuration} {@code Class} objects:
* <pre class="code">
* &#064;RunWith(SpringJUnit4ClassRunner.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.
*
* <p>May be used on any class directly or indirectly annotated with
* {@link org.springframework.stereotype.Component} or on methods annotated with
* {@link Bean}.
* <p>May be used on any class directly or indirectly annotated with {@link
* org.springframework.stereotype.Component @Component} or on methods annotated with
* {@link Bean @Bean}.
*
* <p>If this annotation is not present on a Component or Bean definition, eager
* initialization will occur. If present and set to {@code true}, the
* Bean/Component will not be initialized until referenced by another bean or
* explicitly retrieved from the enclosing
* {@link org.springframework.beans.factory.BeanFactory}. If present and set to
* {@code false}, the bean will be instantiated on startup by bean factories
* that perform eager initialization of singletons.
* <p>If this annotation is not present on a {@code @Component} or {@code @Bean} definition,
* eager initialization will occur. If present and set to {@code true}, the {@code @Bean} or
* {@code @Component} will not be initialized until referenced by another bean or explicitly
* retrieved from the enclosing {@link org.springframework.beans.factory.BeanFactory
* BeanFactory}. If present and set to {@code false}, the bean will be instantiated on
* startup by bean factories that perform eager initialization of singletons.
*
* <p>If Lazy is present on a {@link Configuration @Configuration} class, this
* indicates that all {@link Bean @Bean} methods within that {@code @Configuration}
* should be lazily initialized. If Lazy is present and false on a Bean method
* within a Lazy-annotated Configuration class, this indicates overriding the
* 'default lazy' behavior and that the bean should be eagerly initialized.
* indicates that all {@code @Bean} methods within that {@code @Configuration}
* should be lazily initialized. If {@code @Lazy} is present and false on a {@code @Bean}
* method within a {@code @Lazy}-annotated {@code @Configuration} class, this indicates
* overriding the 'default lazy' behavior and that the bean should be eagerly initialized.
*
* @author Chris Beams
* @since 3.0