Class RefreshableAnnotationConfigApplicationContext
java.lang.Object
org.springframework.core.io.DefaultResourceLoader
org.springframework.context.support.AbstractApplicationContext
org.springframework.context.support.AbstractRefreshableApplicationContext
org.springframework.context.support.AbstractRefreshableConfigApplicationContext
org.springframework.geode.context.annotation.RefreshableAnnotationConfigApplicationContext
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanFactory
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.HierarchicalBeanFactory
,org.springframework.beans.factory.InitializingBean
,org.springframework.beans.factory.ListableBeanFactory
,org.springframework.context.annotation.AnnotationConfigRegistry
,org.springframework.context.ApplicationContext
,org.springframework.context.ApplicationEventPublisher
,org.springframework.context.ConfigurableApplicationContext
,org.springframework.context.Lifecycle
,org.springframework.context.MessageSource
,org.springframework.core.env.EnvironmentCapable
,org.springframework.core.io.ResourceLoader
,org.springframework.core.io.support.ResourcePatternResolver
public class RefreshableAnnotationConfigApplicationContext
extends org.springframework.context.support.AbstractRefreshableConfigApplicationContext
implements org.springframework.context.annotation.AnnotationConfigRegistry
A refreshable
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).- Since:
- 1.3.0
- See Also:
-
BeanDefinition
BeanDefinitionRegistry
BeanNameGenerator
DefaultListableBeanFactory
ApplicationContext
AnnotatedBeanDefinitionReader
AnnotationConfigRegistry
ClassPathBeanDefinitionScanner
ScopeMetadataResolver
AbstractRefreshableConfigApplicationContext
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.core.io.DefaultResourceLoader
org.springframework.core.io.DefaultResourceLoader.ClassPathContextResource
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final boolean
protected static final boolean
Fields inherited from class org.springframework.context.support.AbstractApplicationContext
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, MESSAGE_SOURCE_BEAN_NAME
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
Fields inherited from interface org.springframework.context.ConfigurableApplicationContext
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
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
-
Constructor Summary
ConstructorDescriptionConstructs an new instance of theRefreshableAnnotationConfigApplicationContext
with default container state and no parentApplicationContext
.RefreshableAnnotationConfigApplicationContext
(org.springframework.context.ApplicationContext parent) Constructs a new instance of theRefreshableAnnotationConfigApplicationContext
initialized with the parentApplicationContext
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<org.springframework.beans.factory.support.BeanNameGenerator>
Returns theoptionally
configuredBeanNameGenerator
strategy used by thisApplicationContext
to generatebean names
forbean definitions
.protected org.slf4j.Logger
Returns the configuredLogger
used to log framework messages to the application log.Optional<org.springframework.context.annotation.ScopeMetadataResolver>
Returns theoptionally
configuredScopeMetadataResolver
strategy used by thisApplicationContext
to resolve the scope forbean definitions
.protected boolean
protected boolean
protected void
loadBeanDefinitions
(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory) LoadsBeanDefinitions
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
Re-registers Singleton beans registered with the previousBeanFactory
(prior to refresh) with thisApplicationContext
, iff this context was previously active and subsequently refreshed.protected void
Stores a reference to the previousConfigurableListableBeanFactory
in order to copy its configuration and state onApplicationContext
refresh invocations.void
void
void
setBeanNameGenerator
(org.springframework.beans.factory.support.BeanNameGenerator beanNameGenerator) Configures theBeanNameGenerator
strategy used by thisApplicationContext
to generatebean names
forbean definitions
.void
setScopeMetadataResolver
(org.springframework.context.annotation.ScopeMetadataResolver scopeMetadataResolver) Configures theScopeMetadataResolver
strategy used by thisApplicationContext
to resolve the scope forbean definitions
.Methods inherited from class org.springframework.context.support.AbstractRefreshableConfigApplicationContext
afterPropertiesSet, getConfigLocations, getDefaultConfigLocations, resolvePath, setBeanName, setConfigLocation, setConfigLocations, setId
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext
assertBeanFactoryActive, cancelRefresh, closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferences
Methods inherited from class org.springframework.context.support.AbstractApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroyBeans, doClose, findAllAnnotationsOnBean, 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, removeApplicationListener, resetCommonCaches, setApplicationStartup, setDisplayName, setEnvironment, setParent, start, stop, toString
Methods inherited from class org.springframework.core.io.DefaultResourceLoader
addProtocolResolver, clearResourceCaches, getClassLoader, getProtocolResolvers, getResource, getResourceByPath, getResourceCache, setClassLoader
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.context.ConfigurableApplicationContext
addProtocolResolver, setClassLoader
Methods inherited from interface org.springframework.core.io.ResourceLoader
getClassLoader, getResource
-
Field Details
-
DEFAULT_COPY_CONFIGURATION
protected static final boolean DEFAULT_COPY_CONFIGURATION- See Also:
-
USE_DEFAULT_FILTERS
protected static final boolean USE_DEFAULT_FILTERS- See Also:
-
-
Constructor Details
-
RefreshableAnnotationConfigApplicationContext
public RefreshableAnnotationConfigApplicationContext()Constructs an new instance of theRefreshableAnnotationConfigApplicationContext
with default container state and no parentApplicationContext
. -
RefreshableAnnotationConfigApplicationContext
public RefreshableAnnotationConfigApplicationContext(@Nullable org.springframework.context.ApplicationContext parent) Constructs a new instance of theRefreshableAnnotationConfigApplicationContext
initialized with the parentApplicationContext
. Additionally, this constructor eagerly initializes aConfigurableListableBeanFactory
, unlikeAbstractRefreshableApplicationContext
implementations, but exactly likeGenericApplicationContext
implementations.- Parameters:
parent
- parentApplicationContext
to this child context.- See Also:
-
ApplicationContext
AbstractRefreshableApplicationContext.refreshBeanFactory()
-
-
Method Details
-
setBeanNameGenerator
public void setBeanNameGenerator(@Nullable org.springframework.beans.factory.support.BeanNameGenerator beanNameGenerator) Configures theBeanNameGenerator
strategy used by thisApplicationContext
to generatebean names
forbean definitions
.- Parameters:
beanNameGenerator
-BeanNameGenerator
used to generatebean names
forbean definitions
.- See Also:
-
BeanNameGenerator
-
getBeanNameGenerator
protected Optional<org.springframework.beans.factory.support.BeanNameGenerator> getBeanNameGenerator()Returns theoptionally
configuredBeanNameGenerator
strategy used by thisApplicationContext
to generatebean names
forbean definitions
.- Returns:
- the
BeanNameGenerator
strategy used to generatebean names
forbean definitions
. - See Also:
-
BeanNameGenerator
Optional
-
getLogger
@NonNull protected org.slf4j.Logger getLogger()Returns the configuredLogger
used to log framework messages to the application log.- Returns:
- the configured
Logger
. - See Also:
-
Logger
-
setScopeMetadataResolver
public void setScopeMetadataResolver(@Nullable org.springframework.context.annotation.ScopeMetadataResolver scopeMetadataResolver) Configures theScopeMetadataResolver
strategy used by thisApplicationContext
to resolve the scope forbean definitions
.- Parameters:
scopeMetadataResolver
-ScopeMetadataResolver
used to resolve the scope ofbean definitions
.- See Also:
-
ScopeMetadataResolver
-
getScopeMetadataResolver
public Optional<org.springframework.context.annotation.ScopeMetadataResolver> getScopeMetadataResolver()Returns theoptionally
configuredScopeMetadataResolver
strategy used by thisApplicationContext
to resolve the scope forbean definitions
.- Returns:
- the configured
ScopeMetadataResolver
used to resolve the scope forbean definitions
. - See Also:
-
ScopeMetadataResolver
Optional
-
isCopyConfigurationEnabled
protected boolean isCopyConfigurationEnabled() -
isUsingDefaultFilters
protected boolean isUsingDefaultFilters() -
loadBeanDefinitions
protected void loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory) throws org.springframework.beans.BeansException LoadsBeanDefinitions
from Annotation configuration (component) classes as well as from other resource locations (e.g. XML).- Specified by:
loadBeanDefinitions
in classorg.springframework.context.support.AbstractRefreshableApplicationContext
- Parameters:
beanFactory
-DefaultListableBeanFactory
to configure.- Throws:
org.springframework.beans.BeansException
- if loading and configuring theBeanDefintions
for the targetDefaultListableBeanFactory
fails.- See Also:
-
DefaultListableBeanFactory
newAnnotatedBeanDefinitionReader(BeanDefinitionRegistry)
newClassBeanDefinitionScanner(BeanDefinitionRegistry)
AbstractRefreshableConfigApplicationContext.getConfigLocations()
-
newAnnotatedBeanDefinitionReader
protected org.springframework.context.annotation.AnnotatedBeanDefinitionReader newAnnotatedBeanDefinitionReader(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) -
newClassBeanDefinitionScanner
protected org.springframework.context.annotation.ClassPathBeanDefinitionScanner newClassBeanDefinitionScanner(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) -
onRefresh
protected void onRefresh()Re-registers Singleton beans registered with the previousBeanFactory
(prior to refresh) with thisApplicationContext
, iff this context was previously active and subsequently refreshed.- Overrides:
onRefresh
in classorg.springframework.context.support.AbstractApplicationContext
- See Also:
-
ConfigurableBeanFactory.copyConfigurationFrom(ConfigurableBeanFactory)
SingletonBeanRegistry.registerSingleton(String, Object)
AbstractRefreshableApplicationContext.getBeanFactory()
-
prepareRefresh
protected void prepareRefresh()Stores a reference to the previousConfigurableListableBeanFactory
in order to copy its configuration and state onApplicationContext
refresh invocations.- Overrides:
prepareRefresh
in classorg.springframework.context.support.AbstractApplicationContext
- See Also:
-
AbstractRefreshableApplicationContext.getBeanFactory()
-
register
- Specified by:
register
in interfaceorg.springframework.context.annotation.AnnotationConfigRegistry
-
scan
- Specified by:
scan
in interfaceorg.springframework.context.annotation.AnnotationConfigRegistry
-