Interface BeanRegistry

All Known Implementing Classes:
BeanRegistryAdapter

public interface BeanRegistry
Used in BeanRegistrar.register(BeanRegistry, Environment) to expose programmatic bean registration capabilities.
Since:
7.0
Author:
Sebastien Deleuze
  • Method Details

    • registerBean

      <T> String registerBean(Class<T> beanClass)
      Register a bean from the given bean class, which will be instantiated using the related resolvable constructor if any.
      Parameters:
      beanClass - the class of the bean
      Returns:
      the generated bean name
    • registerBean

      <T> String registerBean(Class<T> beanClass, Consumer<BeanRegistry.Spec<T>> customizer)
      Register a bean from the given bean class, customizing it with the customizer callback. The bean will be instantiated using the supplier that can be configured in the customizer callback, or will be tentatively instantiated with its resolvable constructor otherwise.
      Parameters:
      beanClass - the class of the bean
      customizer - callback to customize other bean properties than the name
      Returns:
      the generated bean name
    • registerBean

      <T> void registerBean(String name, Class<T> beanClass)
      Register a bean from the given bean class, which will be instantiated using the related resolvable constructor if any.
      Parameters:
      name - the name of the bean
      beanClass - the class of the bean
    • registerBean

      <T> void registerBean(String name, Class<T> beanClass, Consumer<BeanRegistry.Spec<T>> customizer)
      Register a bean from the given bean class, customizing it with the customizer callback. The bean will be instantiated using the supplier that can be configured in the customizer callback, or will be tentatively instantiated with its resolvable constructor otherwise.
      Parameters:
      name - the name of the bean
      beanClass - the class of the bean
      customizer - callback to customize other bean properties than the name