Interface BeanDefinitionService

All Known Implementing Classes:
DefaultBeanDefinitionService

@Internal public sealed interface BeanDefinitionService permits DefaultBeanDefinitionService
The API to access bean definitions and bean references. Internal implementation is responsible for loading bean definitions and checking if it's enabled.
Since:
5.0
Author:
Denis Stepanov
  • Method Details

    • addBeanDefinition

      void addBeanDefinition(RuntimeBeanDefinition<?> definition)
      Registers a runtime bean definition so it becomes visible to the provider alongside precompiled definitions.
      Parameters:
      definition - the runtime definition to register, never null
    • removeBeanDefinition

      void removeBeanDefinition(RuntimeBeanDefinition<?> definition)
      Unregisters a runtime bean definition that was previously added.
      Parameters:
      definition - the runtime definition to remove, never null
    • trackDisabled

      void trackDisabled(QualifiedBeanType<?> beanType, List<String> reasons)
      Records that a qualified bean type has been disabled, along with human-readable reasons.
      Parameters:
      beanType - the qualified bean type that has been disabled
      reasons - the reasons explaining why the bean is disabled
    • getEagerInitBeans

      Iterable<BeanDefinition<Object>> getEagerInitBeans(BeanContext beanContext)
      Returns bean definitions that should be initialized eagerly.
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      Returns:
      an iterable of bean definitions that should be eagerly instantiated
    • getProcessedBeans

      Iterable<BeanDefinition<Object>> getProcessedBeans(BeanContext beanContext)
      Returns bean definitions that require contextual processing during startup.
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      Returns:
      an iterable of bean definitions that require processing at startup
    • getParallelBeans

      Iterable<BeanDefinition<Object>> getParallelBeans(BeanContext beanContext)
      Returns bean definitions that are safe to be instantiated in parallel during startup.
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      Returns:
      an iterable of bean definitions eligible for parallel creation
    • getTargetProxyBeans

      Iterable<BeanDefinition<Object>> getTargetProxyBeans(BeanContext beanContext)
      Returns target proxy bean definitions.
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      Returns:
      an iterable of bean definitions that should be treated as target proxy candidates
    • getDisabledBeans

      List<DisabledBean<?>> getDisabledBeans(BeanContext beanContext)
      Returns a disabled beans.
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      Returns:
      a list of disabled beans with their associated reasons
    • exists

      boolean exists(Class<?> beanType)
      Returns whether at least one bean definition exists for the given raw type. This is a lightweight existence check and does not consider qualifiers.
      Parameters:
      beanType - the raw type to check
      Returns:
      true if at least one definition of the given type is known; false otherwise
    • getBeanDefinitions

      default List<BeanDefinition<Object>> getBeanDefinitions(BeanContext beanContext, @Nullable Predicate<BeanDefinition<Object>> defPredicate)
      Resolves enabled bean definitions.
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      defPredicate - optional filter applied to definitions
      Returns:
      a list of loaded bean definitions matching the filter
    • getBeanDefinitions

      default List<BeanDefinition<Object>> getBeanDefinitions(BeanContext beanContext, @Nullable Predicate<BeanDefinitionReference<Object>> refPredicate, @Nullable Predicate<BeanDefinition<Object>> defPredicate)
      Resolves enabled bean definitions.
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      refPredicate - optional filter applied to references
      defPredicate - optional filter applied to definitions
      Returns:
      a list of loaded bean definitions matching the filters
    • getBeanDefinitions

      <B> Iterable<BeanDefinition<B>> getBeanDefinitions(BeanContext beanContext, Argument<B> beanType, @Nullable Predicate<BeanDefinitionReference<B>> refPredicate, @Nullable Predicate<BeanDefinition<B>> defPredicate)
      Resolves enabled bean definitions.
      Type Parameters:
      B - the bean generic type
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      beanType - the bean type to resolve
      refPredicate - optional filter applied to references
      defPredicate - optional filter applied to definitions
      Returns:
      an iterable over matching bean definitions; iteration may trigger loading
    • getBeanDefinitions

      <B> Iterable<BeanDefinition<B>> getBeanDefinitions(BeanResolutionContext beanResolutionContext, Argument<B> beanType, @Nullable Predicate<BeanDefinitionReference<B>> refPredicate, @Nullable Predicate<BeanDefinition<B>> defPredicate)
      Resolves enabled bean definitions.
      Type Parameters:
      B - the bean generic type
      Parameters:
      beanResolutionContext - the resolution context to eliminate disabled beans
      beanType - the bean context to eliminate disabled beans
      refPredicate - optional filter applied to references prior to loading; may be null
      defPredicate - optional filter applied to loaded definitions; may be null
      Returns:
      an iterable over matching bean definitions]]
    • getBeanReferences

      Iterable<BeanDefinitionReference<Object>> getBeanReferences(BeanContext beanContext)
      Returns all enabled bean references.
      Parameters:
      beanContext - the context for which references are requested
      Returns:
      an iterable of bean definition references
    • getBeanReferences

      List<BeanDefinitionReference<Object>> getBeanReferences()
      Returns all bean references.
      Returns:
      a list of all known bean definition references
    • findBeanDefinitionByDefinitionClass

      <T> @Nullable BeanDefinition<T> findBeanDefinitionByDefinitionClass(BeanContext beanContext, Class<? extends BeanDefinition<T>> definitionClass)
      Finds the bean definition that was compiled as the given definition class.

      Candidates are narrowed by the definition's own class name, as reported by BeanDefinitionReference.getBeanDefinitionName(), so unmatched definitions are never loaded; each candidate is then loaded until one of them is the requested class, so a name that two references share, as separate class loaders can make happen, does not hide the definition that was asked for. The instance returned is the one this service hands out for every other lookup.

      Type Parameters:
      T - the bean type
      Parameters:
      beanContext - the bean context to eliminate disabled beans
      definitionClass - the class of the compiled definition
      Returns:
      the enabled definition compiled as that class, or null if there is none
      Since:
      5.2.0
    • registerConfiguration

      void registerConfiguration(BeanConfiguration configuration)
      Registers a bean configuration.
      Parameters:
      configuration - the configuration to register
    • reset

      void reset()
      Resets the provider by clearing internal caches and runtime registrations. Intended for container lifecycle management and test scenarios.
    • initialize

      void initialize(BeanContext beanContext)
      Initializes the provider for use with the given context. Implementations may perform warm-up and indexing.
      Parameters:
      beanContext - the bean context