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

Field Summary
 
Fields inherited from interface org.springframework.context.ConfigurableApplicationContext
CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
 
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
 
Method Summary
 void register(Class<?>... annotatedClasses)
          Register one or more annotated classes to be processed.
 void scan(String... basePackages)
          Perform a scan within the specified base packages.
 void setBeanNameGenerator(BeanNameGenerator beanNameGenerator)
          Set the BeanNameGenerator to use for detected bean classes.
 void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver)
          Set the ScopeMetadataResolver to use for detected bean classes.
 
Methods inherited from interface org.springframework.context.ConfigurableApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, getEnvironment, isActive, refresh, registerShutdownHook, setEnvironment, setId, setParent
 
Methods inherited from interface org.springframework.context.ApplicationContext
getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate
 
Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch
 
Methods inherited from interface org.springframework.context.MessageSource
getMessage, getMessage, getMessage
 
Methods inherited from interface org.springframework.context.ApplicationEventPublisher
publishEvent
 
Methods inherited from interface org.springframework.core.io.support.ResourcePatternResolver
getResources
 
Methods inherited from interface org.springframework.core.io.ResourceLoader
getClassLoader, getResource
 
Methods inherited from interface org.springframework.context.Lifecycle
isRunning, start, stop
 

Method Detail

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()