|
|
|
@ -22,20 +22,19 @@ import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
|
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigUtils;
|
|
|
|
|
import org.springframework.context.annotation.AnnotationScopeMetadataResolver;
|
|
|
|
|
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.annotation.ScopeMetadataResolver;
|
|
|
|
|
import org.springframework.core.env.ConfigurableEnvironment;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@link EmbeddedWebApplicationContext} that accepts annotated classes as input - in
|
|
|
|
|
* particular {@link org.springframework.context.annotation.Configuration
|
|
|
|
|
* <code>@Configuration</code>}-annotated classes, but also plain
|
|
|
|
|
* {@link org.springframework.stereotype.Component <code>@Component</code>} classes and
|
|
|
|
|
* JSR-330 compliant classes using {@code javax.inject} annotations. Allows for
|
|
|
|
|
* registering classes one by one (specifying class names as config location) as well as
|
|
|
|
|
* for classpath scanning (specifying base packages as config location).
|
|
|
|
|
* particular {@link org.springframework.context.annotation.Configuration @Configuration}
|
|
|
|
|
* -annotated classes, but also plain {@link Component @Component} classes and JSR-330
|
|
|
|
|
* compliant classes using {@code javax.inject} annotations. Allows for registering
|
|
|
|
|
* classes one by one (specifying class names as config location) as well as for classpath
|
|
|
|
|
* scanning (specifying base packages as config location).
|
|
|
|
|
* <p>
|
|
|
|
|
* Note: In case of multiple {@code @Configuration} classes, later {@code @Bean}
|
|
|
|
|
* definitions will override ones defined in earlier loaded files. This can be leveraged
|
|
|
|
@ -72,8 +71,8 @@ public class AnnotationConfigEmbeddedWebApplicationContext extends
|
|
|
|
|
* Create a new {@link AnnotationConfigEmbeddedWebApplicationContext}, deriving bean
|
|
|
|
|
* definitions from the given annotated classes and automatically refreshing the
|
|
|
|
|
* context.
|
|
|
|
|
* @param annotatedClasses one or more annotated classes, e.g. {@link Configuration
|
|
|
|
|
* <code>@Configuration</code>} classes
|
|
|
|
|
* @param annotatedClasses one or more annotated classes, e.g. {@code @Configuration}
|
|
|
|
|
* classes
|
|
|
|
|
*/
|
|
|
|
|
public AnnotationConfigEmbeddedWebApplicationContext(Class<?>... annotatedClasses) {
|
|
|
|
|
this();
|
|
|
|
@ -148,8 +147,8 @@ public class AnnotationConfigEmbeddedWebApplicationContext extends
|
|
|
|
|
* <p>
|
|
|
|
|
* Calls to {@link #register} are idempotent; adding the same annotated class more
|
|
|
|
|
* than once has no additional effect.
|
|
|
|
|
* @param annotatedClasses one or more annotated classes, e.g. {@link Configuration
|
|
|
|
|
* <code>@Configuration</code>} classes
|
|
|
|
|
* @param annotatedClasses one or more annotated classes, e.g. {@code @Configuration}
|
|
|
|
|
* classes
|
|
|
|
|
* @see #scan(String...)
|
|
|
|
|
* @see #refresh()
|
|
|
|
|
*/
|
|
|
|
|