Top Description Methods
org.springframework.context.annotation

public Interface ImportBeanDefinitionRegistrar

Known Direct Implementers
org.springframework.context.annotation.AspectJAutoProxyRegistrar, org.springframework.context.annotation.AutoProxyRegistrar
Imports
org.springframework.beans.factory.support.BeanDefinitionRegistry, .BeanDefinitionRegistryPostProcessor, .BeanNameGenerator, org.springframework.core.type.AnnotationMetadata

Interface to be implemented by types that register additional bean definitions when processing @Configuration classes. Useful when operating at the bean definition level (as opposed to @Bean method/instance level) is desired or necessary.

Along with @Configuration and ImportSelector, classes of this type may be provided to the @Import annotation (or may also be returned from an ImportSelector).

An ImportBeanDefinitionRegistrar may implement any of the following Aware interfaces, and their respective methods will be called prior to registerBeanDefinitions:

Alternatively, the class may provide a single constructor with one or more of the following supported parameter types:

See implementations and associated unit tests for usage examples.

Authors
Chris Beams, Juergen Hoeller
Since
3.1
See Also
Import, ImportSelector, Configuration

Method Summary

Modifier and TypeMethod and Description
public default void
registerBeanDefinitions(AnnotationMetadata
annotation metadata of the importing class
importingClassMetadata
,
BeanDefinitionRegistry
current bean definition registry
registry
,
BeanNameGenerator
the bean name generator strategy for imported beans: ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR by default, or a user-provided one if ConfigurationClassPostProcessor#setBeanNameGenerator has been set. In the latter case, the passed-in strategy will be the same used for component scanning in the containing application context (otherwise, the default component-scan naming strategy is AnnotationBeanNameGenerator#INSTANCE).
importBeanNameGenerator
)

Register bean definitions as necessary based on the given annotation metadata of the importing @Configuration class.

public default void
registerBeanDefinitions(AnnotationMetadata
annotation metadata of the importing class
importingClassMetadata
,
BeanDefinitionRegistry
current bean definition registry
registry
)

Register bean definitions as necessary based on the given annotation metadata of the importing @Configuration class.

Method Detail

registerBeanDefinitionsback to summary
public default void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator)

Register bean definitions as necessary based on the given annotation metadata of the importing @Configuration class.

Note that BeanDefinitionRegistryPostProcessor types may not be registered here, due to lifecycle constraints related to @Configuration class processing.

The default implementation delegates to registerBeanDefinitions(AnnotationMetadata, BeanDefinitionRegistry).

Parameters
importingClassMetadata:AnnotationMetadata

annotation metadata of the importing class

registry:BeanDefinitionRegistry

current bean definition registry

importBeanNameGenerator:BeanNameGenerator

the bean name generator strategy for imported beans: ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR by default, or a user-provided one if ConfigurationClassPostProcessor#setBeanNameGenerator has been set. In the latter case, the passed-in strategy will be the same used for component scanning in the containing application context (otherwise, the default component-scan naming strategy is AnnotationBeanNameGenerator#INSTANCE).

Since
5.2
See Also
ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR, ConfigurationClassPostProcessor#setBeanNameGenerator
registerBeanDefinitionsback to summary
public default void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry)

Register bean definitions as necessary based on the given annotation metadata of the importing @Configuration class.

Note that BeanDefinitionRegistryPostProcessor types may not be registered here, due to lifecycle constraints related to @Configuration class processing.

The default implementation is empty.

Parameters
importingClassMetadata:AnnotationMetadata

annotation metadata of the importing class

registry:BeanDefinitionRegistry

current bean definition registry