Package io.micronaut.context.beans
Interface BeanDefinitionService
- All Known Implementing Classes:
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 Summary
Modifier and TypeMethodDescriptionvoidaddBeanDefinition(RuntimeBeanDefinition<?> definition) Registers a runtime bean definition so it becomes visible to the provider alongside precompiled definitions.booleanReturns whether at least one bean definition exists for the given raw type.<B> Iterable<BeanDefinition<B>> getBeanDefinitions(BeanContext beanContext, Argument<B> beanType, @Nullable Predicate<BeanDefinitionReference<B>> refPredicate, @Nullable Predicate<BeanDefinition<B>> defPredicate) Resolves enabled bean definitions.default List<BeanDefinition<Object>> getBeanDefinitions(BeanContext beanContext, @Nullable Predicate<BeanDefinition<Object>> defPredicate) Resolves enabled bean definitions.default List<BeanDefinition<Object>> getBeanDefinitions(BeanContext beanContext, @Nullable Predicate<BeanDefinitionReference<Object>> refPredicate, @Nullable Predicate<BeanDefinition<Object>> defPredicate) Resolves enabled bean definitions.<B> Iterable<BeanDefinition<B>> getBeanDefinitions(BeanResolutionContext beanResolutionContext, Argument<B> beanType, @Nullable Predicate<BeanDefinitionReference<B>> refPredicate, @Nullable Predicate<BeanDefinition<B>> defPredicate) Resolves enabled bean definitions.Returns all bean references.getBeanReferences(BeanContext beanContext) Returns all enabled bean references.List<DisabledBean<?>> getDisabledBeans(BeanContext beanContext) Returns a disabled beans.getEagerInitBeans(BeanContext beanContext) Returns bean definitions that should be initialized eagerly.getParallelBeans(BeanContext beanContext) Returns bean definitions that are safe to be instantiated in parallel during startup.getProcessedBeans(BeanContext beanContext) Returns bean definitions that require contextual processing during startup.getTargetProxyBeans(BeanContext beanContext) Returns target proxy bean definitions.voidinitialize(BeanContext beanContext) Initializes the provider for use with the given context.voidregisterConfiguration(BeanConfiguration configuration) Registers a bean configuration.voidremoveBeanDefinition(RuntimeBeanDefinition<?> definition) Unregisters a runtime bean definition that was previously added.voidreset()Resets the provider by clearing internal caches and runtime registrations.voidtrackDisabled(QualifiedBeanType<?> beanType, List<String> reasons) Records that a qualified bean type has been disabled, along with human-readable reasons.
-
Method Details
-
addBeanDefinition
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
Unregisters a runtime bean definition that was previously added.- Parameters:
definition- the runtime definition to remove, never null
-
trackDisabled
Records that a qualified bean type has been disabled, along with human-readable reasons.- Parameters:
beanType- the qualified bean type that has been disabledreasons- the reasons explaining why the bean is disabled
-
getEagerInitBeans
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
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
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
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
Returns a disabled beans.- Parameters:
beanContext- the bean context to eliminate disabled beans- Returns:
- a list of disabled beans with their associated reasons
-
exists
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 beansdefPredicate- 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 beansrefPredicate- optional filter applied to referencesdefPredicate- 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 beansbeanType- the bean type to resolverefPredicate- optional filter applied to referencesdefPredicate- 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 beansbeanType- the bean context to eliminate disabled beansrefPredicate- optional filter applied to references prior to loading; may be nulldefPredicate- optional filter applied to loaded definitions; may be null- Returns:
- an iterable over matching bean definitions]]
-
getBeanReferences
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
-
registerConfiguration
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
Initializes the provider for use with the given context. Implementations may perform warm-up and indexing.- Parameters:
beanContext- the bean context
-