Package de.hybris.platform.spring
Class LazyInitOverrideBeanFactoryPostProcessor
java.lang.Object
de.hybris.platform.spring.LazyInitOverrideBeanFactoryPostProcessor
- All Implemented Interfaces:
org.springframework.beans.factory.config.BeanFactoryPostProcessor
public class LazyInitOverrideBeanFactoryPostProcessor
extends Object
implements org.springframework.beans.factory.config.BeanFactoryPostProcessor
This BeanFactoryPostProcessor was created to make sure that some beans can be eagerly loaded even if default setting
is set to lazy loading.
This is useful especially for some configuration beans like ListMergeDirective which would never be loaded in
lazy mode because there is nothing that requires them explicitly, but without them system will misbehave.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<?>Helper method for getting class for name without throwing exception.protected booleanprotected Optional<org.springframework.beans.factory.config.BeanDefinition>getMergedBeanDefinition(String beanName, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Helper method for getting MergedBeanDefintion and ignoring potential errors by returning Optional.emptyprotected booleanisSupportedClass(Class<?> clazz) Predicate finding if given class exists in set of supported classes (is assignable to any of them)protected voidoverrideLazyInit(String beanName, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Overrides lazyInit property for given bean definition.voidpostProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Searches for bean definitions that are not abstract and are of particular class.voidsetEagerlyLoadedClasses(List<Class<?>> eagerlyLoadedClasses) voidsetLazyInit(boolean lazyInit)
-
Constructor Details
-
LazyInitOverrideBeanFactoryPostProcessor
public LazyInitOverrideBeanFactoryPostProcessor()
-
-
Method Details
-
postProcessBeanFactory
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException Searches for bean definitions that are not abstract and are of particular class. For those bean definitions it overrides lazyInit property.- Specified by:
postProcessBeanFactoryin interfaceorg.springframework.beans.factory.config.BeanFactoryPostProcessor- Throws:
org.springframework.beans.BeansException
-
getMergedBeanDefinition
protected Optional<org.springframework.beans.factory.config.BeanDefinition> getMergedBeanDefinition(String beanName, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Helper method for getting MergedBeanDefintion and ignoring potential errors by returning Optional.empty -
forName
Helper method for getting class for name without throwing exception. Null returned for non existing classes will be ignored in filtering stream. -
isSupportedClass
Predicate finding if given class exists in set of supported classes (is assignable to any of them) -
overrideLazyInit
protected void overrideLazyInit(String beanName, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Overrides lazyInit property for given bean definition. -
setEagerlyLoadedClasses
-
getEagerlyLoadedClasses
-
setLazyInit
public void setLazyInit(boolean lazyInit) -
getLazyInit
protected boolean getLazyInit()
-