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

    Fields
    Modifier and Type
    Field
    Description
    protected 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

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Optional<org.springframework.beans.factory.support.BeanNameGenerator>
    Returns the optionally configured BeanNameGenerator strategy used by this ApplicationContext to generate bean names for bean definitions.
    protected org.slf4j.Logger
    Returns the configured Logger used to log framework messages to the application log.
    Optional<org.springframework.context.annotation.ScopeMetadataResolver>
    Returns the optionally configured ScopeMetadataResolver strategy used by this ApplicationContext to resolve the scope for bean definitions.
    protected boolean
     
    protected boolean
     
    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
    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
    Stores a reference to the previous ConfigurableListableBeanFactory in order to copy its configuration and state on ApplicationContext refresh invocations.
    void
    register(Class<?>... componentClasses)
    void
    scan(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.

    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 the RefreshableAnnotationConfigApplicationContext with default container state and no parent ApplicationContext.
      See Also:
    • RefreshableAnnotationConfigApplicationContext

      public RefreshableAnnotationConfigApplicationContext(@Nullable org.springframework.context.ApplicationContext parent)
      Constructs a new instance of the RefreshableAnnotationConfigApplicationContext initialized with the parent ApplicationContext. Additionally, this constructor eagerly initializes a ConfigurableListableBeanFactory, unlike AbstractRefreshableApplicationContext implementations, but exactly like GenericApplicationContext implementations.
      Parameters:
      parent - parent ApplicationContext to this child context.
      See Also:
      • ApplicationContext
      • AbstractRefreshableApplicationContext.refreshBeanFactory()
  • Method Details

    • setBeanNameGenerator

      public void setBeanNameGenerator(@Nullable org.springframework.beans.factory.support.BeanNameGenerator beanNameGenerator)
      Configures the BeanNameGenerator strategy used by this ApplicationContext to generate bean names for bean definitions.
      Parameters:
      beanNameGenerator - BeanNameGenerator used to generate bean names for bean definitions.
      See Also:
      • BeanNameGenerator
    • getBeanNameGenerator

      protected 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.
      Returns:
      the BeanNameGenerator strategy used to generate bean names for bean definitions.
      See Also:
    • getLogger

      @NonNull protected org.slf4j.Logger getLogger()
      Returns the configured Logger 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 the ScopeMetadataResolver strategy used by this ApplicationContext to resolve the scope for bean definitions.
      Parameters:
      scopeMetadataResolver - ScopeMetadataResolver used to resolve the scope of bean definitions.
      See Also:
      • ScopeMetadataResolver
    • getScopeMetadataResolver

      public Optional<org.springframework.context.annotation.ScopeMetadataResolver> getScopeMetadataResolver()
      Returns the optionally configured ScopeMetadataResolver strategy used by this ApplicationContext to resolve the scope for bean definitions.
      Returns:
      the configured ScopeMetadataResolver used to resolve the scope for bean definitions.
      See Also:
    • isCopyConfigurationEnabled

      protected boolean isCopyConfigurationEnabled()
    • isUsingDefaultFilters

      protected boolean isUsingDefaultFilters()
    • loadBeanDefinitions

      protected void loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
      Loads BeanDefinitions from Annotation configuration (component) classes as well as from other resource locations (e.g. XML).
      Specified by:
      loadBeanDefinitions in class org.springframework.context.support.AbstractRefreshableApplicationContext
      Parameters:
      beanFactory - DefaultListableBeanFactory to configure.
      Throws:
      org.springframework.beans.BeansException - if loading and configuring the BeanDefintions for the target DefaultListableBeanFactory fails.
      See Also:
    • 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 previous BeanFactory (prior to refresh) with this ApplicationContext, iff this context was previously active and subsequently refreshed.
      Overrides:
      onRefresh in class org.springframework.context.support.AbstractApplicationContext
      See Also:
      • ConfigurableBeanFactory.copyConfigurationFrom(ConfigurableBeanFactory)
      • SingletonBeanRegistry.registerSingleton(String, Object)
      • AbstractRefreshableApplicationContext.getBeanFactory()
    • prepareRefresh

      protected void prepareRefresh()
      Stores a reference to the previous ConfigurableListableBeanFactory in order to copy its configuration and state on ApplicationContext refresh invocations.
      Overrides:
      prepareRefresh in class org.springframework.context.support.AbstractApplicationContext
      See Also:
      • AbstractRefreshableApplicationContext.getBeanFactory()
    • register

      public void register(Class<?>... componentClasses)
      Specified by:
      register in interface org.springframework.context.annotation.AnnotationConfigRegistry
    • scan

      public void scan(String... basePackages)
      Specified by:
      scan in interface org.springframework.context.annotation.AnnotationConfigRegistry