org.springframework.context.annotation
Interface AnnotationConfigCapableApplicationContext
- All Superinterfaces:
- ApplicationContext, ApplicationEventPublisher, BeanFactory, ConfigurableApplicationContext, EnvironmentCapable, HierarchicalBeanFactory, Lifecycle, ListableBeanFactory, MessageSource, ResourceLoader, ResourcePatternResolver
- All Known Implementing Classes:
- AnnotationConfigApplicationContext, AnnotationConfigWebApplicationContext
public interface AnnotationConfigCapableApplicationContext
- extends ConfigurableApplicationContext
Extension of the ConfigurableApplicationContext interface to be implemented by
application contexts that are capable of registering or scanning for annotated classes
including @Configuration classes.
This subinterface is not intended for everyday use:
AnnotationConfigApplicationContext and its web variant
AnnotationConfigWebApplicationContext should be used directly in most cases.
The notable exception to the above is when designing
ApplicationContextInitializer (ACI) implementations: it may be desirable to design an
ACI such that it may be used interchangeably against a standalone or web-capable
"AnnotationConfig" application context. For example:
public class MyACI
implements ApplicationContextInitializer<AnnotationConfigCapableApplicationContext> {
void initialize(AnnotationConfigCapableApplicationContext context) {
context.register(MyConfig1.class, MyConfig2.class);
context.scan("pkg1", "pkg2");
// ...
}
}
See ApplicationContextInitializer Javadoc for further usage details.
- Since:
- 3.1
- Author:
- Chris Beams
- See Also:
AnnotationConfigApplicationContext,
AnnotationConfigWebApplicationContext,
ApplicationContextInitializer
| Methods inherited from interface org.springframework.context.ConfigurableApplicationContext |
addApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, getEnvironment, isActive, refresh, registerShutdownHook, setEnvironment, setId, setParent |
setScopeMetadataResolver
void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver)
- Set the
ScopeMetadataResolver to use for detected bean classes.
The default is an AnnotationScopeMetadataResolver.
setBeanNameGenerator
void setBeanNameGenerator(BeanNameGenerator beanNameGenerator)
- Set the
BeanNameGenerator to use for detected bean classes.
The default is an AnnotationBeanNameGenerator.
register
void register(Class<?>... annotatedClasses)
- Register one or more annotated classes to be processed.
Note that
ConfigurableApplicationContext.refresh() must be called in order for the context to fully
process the new class.
Calls to register(java.lang.Class>...) are idempotent; adding the same
annotated class more than once has no additional effect.
- Parameters:
annotatedClasses - one or more annotated classes,
e.g. @Configuration classes- See Also:
scan(String...),
ConfigurableApplicationContext.refresh()
scan
void scan(String... basePackages)
- Perform a scan within the specified base packages.
Note that
ConfigurableApplicationContext.refresh() must be called in order for the context to
fully process the new class.
- Parameters:
basePackages - the packages to check for annotated classes- See Also:
register(Class...),
ConfigurableApplicationContext.refresh()