public class RefreshableAnnotationConfigApplicationContext
extends org.springframework.context.support.AbstractRefreshableConfigApplicationContext
implements org.springframework.context.annotation.AnnotationConfigRegistry
ApplicationContext
capable of loading component classes
used for
Annotation
based configuration in addition to scanning configuration locations
, and then
providing the ability to reload/refresh the context at some point later during runtime.
DISCLAIMER: Currently, this ApplicationContext
implementation (and extension) is being used exclusively for
testing and experimental (R&D) purposes. It was designed around Apache Geode's forced-disconnect / auto-reconnect
functionality, providing support for this behavior inside a Spring context. Specifically, this concern is only
applicable when using Spring Boot to configure and bootstrap Apache Geode peer member
Cache
applications, such as when annotating your Spring Boot application with
SDG's PeerCacheApplication
annotation. This ApplicationContext
implementation is not recommended for
use in Production Systems/Applications (yet).BeanDefinition
,
BeanDefinitionRegistry
,
BeanNameGenerator
,
DefaultListableBeanFactory
,
ApplicationContext
,
AnnotatedBeanDefinitionReader
,
AnnotationConfigRegistry
,
ClassPathBeanDefinitionScanner
,
ScopeMetadataResolver
,
AbstractRefreshableConfigApplicationContext
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEFAULT_COPY_CONFIGURATION |
protected static boolean |
USE_DEFAULT_FILTERS |
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, MESSAGE_SOURCE_BEAN_NAME
APPLICATION_STARTUP_BEAN_NAME, CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SHUTDOWN_HOOK_THREAD_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME
Constructor and Description |
---|
RefreshableAnnotationConfigApplicationContext()
Constructs an new instance of the
RefreshableAnnotationConfigApplicationContext
with default container state and no parent ApplicationContext . |
RefreshableAnnotationConfigApplicationContext(org.springframework.context.ApplicationContext parent)
Constructs a new instance of the
RefreshableAnnotationConfigApplicationContext initialized with
the parent ApplicationContext . |
Modifier and Type | Method and Description |
---|---|
protected java.util.Optional<org.springframework.beans.factory.support.BeanNameGenerator> |
getBeanNameGenerator()
Returns the
optionally configured BeanNameGenerator strategy used by this
ApplicationContext to generate bean names for bean definitions . |
protected org.slf4j.Logger |
getLogger()
Returns the configured
Logger used to log framework messages to the application log. |
java.util.Optional<org.springframework.context.annotation.ScopeMetadataResolver> |
getScopeMetadataResolver()
Returns the
optionally configured ScopeMetadataResolver strategy used by
this ApplicationContext to resolve the scope for bean definitions . |
protected boolean |
isCopyConfigurationEnabled() |
protected boolean |
isUsingDefaultFilters() |
protected void |
loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
Loads
BeanDefinitions from Annotation configuration (component) classes
as well as from other resource locations (e.g. |
protected org.springframework.context.annotation.AnnotatedBeanDefinitionReader |
newAnnotatedBeanDefinitionReader(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
protected org.springframework.context.annotation.ClassPathBeanDefinitionScanner |
newClassBeanDefinitionScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
protected void |
onRefresh()
Re-registers Singleton beans registered with the previous
BeanFactory
(prior to refresh) with this ApplicationContext , iff this context was previously active
and subsequently refreshed. |
protected void |
prepareRefresh()
Stores a reference to the previous
ConfigurableListableBeanFactory in order to copy its configuration
and state on ApplicationContext refresh invocations. |
void |
register(java.lang.Class<?>... componentClasses) |
void |
scan(java.lang.String... basePackages) |
void |
setBeanNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator beanNameGenerator)
Configures the
BeanNameGenerator strategy used by this ApplicationContext to generate
bean names for bean definitions . |
void |
setScopeMetadataResolver(org.springframework.context.annotation.ScopeMetadataResolver scopeMetadataResolver)
Configures the
ScopeMetadataResolver strategy used by this ApplicationContext to resolve
the scope for bean definitions . |
afterPropertiesSet, getConfigLocations, getDefaultConfigLocations, resolvePath, setBeanName, setConfigLocation, setConfigLocations, setId
assertBeanFactoryActive, cancelRefresh, closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferences
addApplicationListener, addBeanFactoryPostProcessor, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroy, destroyBeans, doClose, findAnnotationOnBean, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationName, getApplicationStartup, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResourcePatternResolver, getResources, getStartupDate, getType, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, initPropertySources, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, onClose, postProcessBeanFactory, prepareBeanFactory, publishEvent, publishEvent, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, resetCommonCaches, setApplicationStartup, setDisplayName, setEnvironment, setParent, start, stop, toString
addProtocolResolver, clearResourceCaches, getClassLoader, getProtocolResolvers, getResource, getResourceByPath, getResourceCache, setClassLoader
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
protected static final boolean DEFAULT_COPY_CONFIGURATION
protected static final boolean USE_DEFAULT_FILTERS
public RefreshableAnnotationConfigApplicationContext()
RefreshableAnnotationConfigApplicationContext
with default container state and no parent ApplicationContext
.public RefreshableAnnotationConfigApplicationContext(@Nullable org.springframework.context.ApplicationContext parent)
RefreshableAnnotationConfigApplicationContext
initialized with
the parent ApplicationContext
.
Additionally, this constructor eagerly initializes a ConfigurableListableBeanFactory
,
unlike AbstractRefreshableApplicationContext
implementations,
but exactly like GenericApplicationContext
implementations.parent
- parent ApplicationContext
to this child context.ApplicationContext
,
AbstractRefreshableApplicationContext.refreshBeanFactory()
public void setBeanNameGenerator(@Nullable org.springframework.beans.factory.support.BeanNameGenerator beanNameGenerator)
BeanNameGenerator
strategy used by this ApplicationContext
to generate
bean names
for bean definitions
.beanNameGenerator
- BeanNameGenerator
used to generate bean names
for bean definitions
.BeanNameGenerator
protected java.util.Optional<org.springframework.beans.factory.support.BeanNameGenerator> getBeanNameGenerator()
optionally
configured BeanNameGenerator
strategy used by this
ApplicationContext
to generate bean names
for bean definitions
.BeanNameGenerator
strategy used to generate bean names
for bean definitions
.BeanNameGenerator
,
Optional
@NonNull protected org.slf4j.Logger getLogger()
Logger
used to log framework messages to the application log.Logger
.Logger
public void setScopeMetadataResolver(@Nullable org.springframework.context.annotation.ScopeMetadataResolver scopeMetadataResolver)
ScopeMetadataResolver
strategy used by this ApplicationContext
to resolve
the scope for bean definitions
.scopeMetadataResolver
- ScopeMetadataResolver
used to resolve the scope
of bean definitions
.ScopeMetadataResolver
public java.util.Optional<org.springframework.context.annotation.ScopeMetadataResolver> getScopeMetadataResolver()
optionally
configured ScopeMetadataResolver
strategy used by
this ApplicationContext
to resolve the scope for bean definitions
.ScopeMetadataResolver
used to resolve the scope
for bean definitions
.ScopeMetadataResolver
,
Optional
protected boolean isCopyConfigurationEnabled()
protected boolean isUsingDefaultFilters()
protected void loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
BeanDefinitions
from Annotation configuration (component) classes
as well as from other resource locations (e.g. XML).loadBeanDefinitions
in class org.springframework.context.support.AbstractRefreshableApplicationContext
beanFactory
- DefaultListableBeanFactory
to configure.org.springframework.beans.BeansException
- if loading and configuring the BeanDefintions
for the target
DefaultListableBeanFactory
fails.DefaultListableBeanFactory
,
newAnnotatedBeanDefinitionReader(BeanDefinitionRegistry)
,
newClassBeanDefinitionScanner(BeanDefinitionRegistry)
,
AbstractRefreshableConfigApplicationContext.getConfigLocations()
protected org.springframework.context.annotation.AnnotatedBeanDefinitionReader newAnnotatedBeanDefinitionReader(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
protected org.springframework.context.annotation.ClassPathBeanDefinitionScanner newClassBeanDefinitionScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
protected void onRefresh()
BeanFactory
(prior to refresh) with this ApplicationContext
, iff this context was previously active
and subsequently refreshed.onRefresh
in class org.springframework.context.support.AbstractApplicationContext
ConfigurableBeanFactory.copyConfigurationFrom(ConfigurableBeanFactory)
,
SingletonBeanRegistry.registerSingleton(String, Object)
,
AbstractRefreshableApplicationContext.getBeanFactory()
protected void prepareRefresh()
ConfigurableListableBeanFactory
in order to copy its configuration
and state on ApplicationContext
refresh invocations.prepareRefresh
in class org.springframework.context.support.AbstractApplicationContext
AbstractRefreshableApplicationContext.getBeanFactory()
public void register(java.lang.Class<?>... componentClasses)
register
in interface org.springframework.context.annotation.AnnotationConfigRegistry
public void scan(java.lang.String... basePackages)
scan
in interface org.springframework.context.annotation.AnnotationConfigRegistry