Class BeanInstantiationGuard

  • All Implemented Interfaces:
    org.springframework.beans.factory.config.BeanFactoryPostProcessor
    Direct Known Subclasses:
    BeanInstantiationSubstituter

    public class BeanInstantiationGuard
    extends java.lang.Object
    implements org.springframework.beans.factory.config.BeanFactoryPostProcessor
    Prevents creation of Spring beans based on read-only status.
    Since:
    5.4.6
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String targetName  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void postProcessBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory factory)  
      protected void setBeanDefinitionForReadOnly​(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
      Act on the bean definition registry to make the target bean suitable for read-only mode.
      void setIsWriteDb​(boolean isWriteDb)  
      void setIsWriteRepo​(boolean isWriteRepo)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • targetName

        protected final java.lang.String targetName
    • Constructor Detail

      • BeanInstantiationGuard

        public BeanInstantiationGuard​(ReadOnlyStatus readOnly,
                                      java.lang.String targetName)
        Construct a bean instantiation guard.
        Parameters:
        readOnly - the read-only status
        targetName - the name of a bean that needs to write
    • Method Detail

      • setIsWriteDb

        public void setIsWriteDb​(boolean isWriteDb)
        Parameters:
        isWriteDb - if the target bean needs to write to the database, defaults to false
      • setIsWriteRepo

        public void setIsWriteRepo​(boolean isWriteRepo)
        Parameters:
        isWriteRepo - if the target bean needs to write to the repository, defaults to false
      • postProcessBeanFactory

        public void postProcessBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory factory)
        Specified by:
        postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
      • setBeanDefinitionForReadOnly

        protected void setBeanDefinitionForReadOnly​(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
        Act on the bean definition registry to make the target bean suitable for read-only mode.
        Parameters:
        registry - the bean definition registry