Class AbstractApplicationContextFactory

  • All Implemented Interfaces:
    ApplicationContextFactory, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
    Direct Known Subclasses:
    GenericApplicationContextFactory

    public abstract class AbstractApplicationContextFactory
    extends java.lang.Object
    implements ApplicationContextFactory, org.springframework.context.ApplicationContextAware
    ApplicationContextFactory implementation that takes a parent context and a path to the context to create. When createApplicationContext method is called, the child ApplicationContext will be returned. The child context is not re-created every time it is requested, it is lazily initialized and cached. Clients should ensure that it is closed when it is no longer needed. If a path is not set, the parent will always be returned.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      AbstractApplicationContextFactory​(java.lang.Object... resource)
      Create a factory instance with the resource specified.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and TypeMethodDescription
      org.springframework.context.ConfigurableApplicationContextcreateApplicationContext()
      Creates an ApplicationContext from the provided path.
      protected abstract org.springframework.context.ConfigurableApplicationContextcreateApplicationContext​(org.springframework.context.ConfigurableApplicationContext parent, java.lang.Object... resources) 
      booleanequals​(java.lang.Object obj) 
      protected java.util.Collection<java.lang.Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>>getBeanFactoryPostProcessorClasses()
      Protected access to the list of bean factory post processor classes that should be copied over to the context from the parent.
      inthashCode() 
      protected booleanisCopyConfiguration()
      Protected access for subclasses to the flag determining whether configuration should be copied from parent context.
      protected voidprepareBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory parent, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
      Extension point for special subclasses that want to do more complex things with the bean factory prior to refresh.
      protected voidprepareContext​(org.springframework.context.ConfigurableApplicationContext parent, org.springframework.context.ConfigurableApplicationContext context)
      Extension point for special subclasses that want to do more complex things with the context prior to refresh.
      voidsetApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
      Setter for the parent application context.
      voidsetBeanFactoryPostProcessorClasses​(java.lang.Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>[] beanFactoryPostProcessorClasses)
      Determines which bean factory post processors (like property placeholders) should be copied from the parent context.
      voidsetBeanPostProcessorExcludeClasses​(java.lang.Class<?>[] beanPostProcessorExcludeClasses)
      Determines by exclusion which bean post processors should be copied from the parent context.
      voidsetCopyConfiguration​(boolean copyConfiguration)
      Flag to indicate that configuration such as bean post processors and custom editors should be copied from the parent context.
      java.lang.StringtoString() 
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractApplicationContextFactory

        public AbstractApplicationContextFactory​(java.lang.Object... resource)
        Create a factory instance with the resource specified. The resources are Spring configuration files or java packages containing configuration files.
        Parameters:
        resource - resource to be used in the creation of the ApplicationContext.
    • Method Detail

      • setCopyConfiguration

        public void setCopyConfiguration​(boolean copyConfiguration)
        Flag to indicate that configuration such as bean post processors and custom editors should be copied from the parent context. Defaults to true.
        Parameters:
        copyConfiguration - the flag value to set
      • isCopyConfiguration

        protected final boolean isCopyConfiguration()
        Protected access for subclasses to the flag determining whether configuration should be copied from parent context.
        Returns:
        the flag value
      • setBeanFactoryPostProcessorClasses

        public void setBeanFactoryPostProcessorClasses​(java.lang.Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>[] beanFactoryPostProcessorClasses)
        Determines which bean factory post processors (like property placeholders) should be copied from the parent context. Defaults to PropertyPlaceholderConfigurer and CustomEditorConfigurer.
        Parameters:
        beanFactoryPostProcessorClasses - array of post processor types to be copied
      • setBeanPostProcessorExcludeClasses

        public void setBeanPostProcessorExcludeClasses​(java.lang.Class<?>[] beanPostProcessorExcludeClasses)
        Determines by exclusion which bean post processors should be copied from the parent context. Defaults to BeanFactoryAware (so any post processors that have a reference to the parent bean factory are not copied into the child). Note that these classes do not themselves have to be BeanPostProcessor implementations or sub-interfaces.
        Parameters:
        beanPostProcessorExcludeClasses - the classes to set
      • getBeanFactoryPostProcessorClasses

        protected final java.util.Collection<java.lang.Class<? extends org.springframework.beans.factory.config.BeanFactoryPostProcessor>> getBeanFactoryPostProcessorClasses()
        Protected access to the list of bean factory post processor classes that should be copied over to the context from the parent.
        Returns:
        the classes for post processors that were nominated for copying
      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
                                   throws org.springframework.beans.BeansException
        Setter for the parent application context.
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
        Throws:
        org.springframework.beans.BeansException
        See Also:
        ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
      • createApplicationContext

        protected abstract org.springframework.context.ConfigurableApplicationContext createApplicationContext​(org.springframework.context.ConfigurableApplicationContext parent,
                                                                                                               java.lang.Object... resources)
      • prepareContext

        protected void prepareContext​(org.springframework.context.ConfigurableApplicationContext parent,
                                      org.springframework.context.ConfigurableApplicationContext context)
        Extension point for special subclasses that want to do more complex things with the context prior to refresh. The default implementation does nothing.
        Parameters:
        parent - the parent for the new application context
        context - the new application context before it is refreshed, but after bean factory is initialized
        See Also:
        setBeanFactoryPostProcessorClasses(Class[])
      • prepareBeanFactory

        protected void prepareBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory parent,
                                          org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
        Extension point for special subclasses that want to do more complex things with the bean factory prior to refresh. The default implementation copies all configuration from the parent according to the flag set.
        Parameters:
        parent - the parent bean factory for the new context (will never be null)
        beanFactory - the new bean factory before bean definitions are loaded
        See Also:
        setCopyConfiguration(boolean), DefaultListableBeanFactory.copyConfigurationFrom(ConfigurableBeanFactory)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object