Interface LazyInitializationExcludeFilter

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface LazyInitializationExcludeFilter
Filter that can be used to exclude beans definitions from having their lazy-init set by the LazyInitializationBeanFactoryPostProcessor.

Primarily intended to allow downstream projects to deal with edge-cases in which it is not easy to support lazy-loading (such as in DSLs that dynamically create additional beans). Adding an instance of this filter to the application context can be used for these edge cases.

A typical example would be something like this:

 @Bean
 public static LazyInitializationExcludeFilter integrationLazyInitializationExcludeFilter() {
   return LazyInitializationExcludeFilter.forBeanTypes(IntegrationFlow.class);
 }
 

NOTE: Beans of this type will be instantiated very early in the spring application lifecycle so they should generally be declared static and not have any dependencies.

Since:
2.2.0
Author:
Tyler Van Gorder, Philip Webb
  • Method Summary

    Modifier and Type
    Method
    Description
    forBeanTypes(Class<?>... types)
    Factory method that creates a filter for the given bean types.
    boolean
    isExcluded(String beanName, BeanDefinition beanDefinition, Class<?> beanType)
    Returns true if the specified bean definition should be excluded from having lazy-init automatically set.
  • Method Details

    • isExcluded

      boolean isExcluded(String beanName, BeanDefinition beanDefinition, Class<?> beanType)
      Returns true if the specified bean definition should be excluded from having lazy-init automatically set.
      Parameters:
      beanName - the bean name
      beanDefinition - the bean definition
      beanType - the bean type
      Returns:
      true if lazy-init should not be automatically set
    • forBeanTypes

      static LazyInitializationExcludeFilter forBeanTypes(Class<?>... types)
      Factory method that creates a filter for the given bean types.
      Parameters:
      types - the filtered types
      Returns:
      a new filter instance