Package io.micronaut.context.beans
Class DefaultBeanDefinitionService
java.lang.Object
io.micronaut.context.beans.DefaultBeanDefinitionService
- All Implemented Interfaces:
BeanDefinitionService
@Internal
public final class DefaultBeanDefinitionService
extends Object
implements BeanDefinitionService
The default implementation of
BeanDefinitionService.- Since:
- 5.0
- Author:
- Denis Stepanov
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultBeanDefinitionService(@NonNull BeanContextConfiguration contextConfiguration) Creates a new bean context with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBeanDefinition(@NonNull 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, Predicate<BeanDefinitionReference<B>> refPredicate, Predicate<BeanDefinition<B>> defPredicate) Resolves enabled bean definitions.<B> Iterable<BeanDefinition<B>>getBeanDefinitions(BeanResolutionContext beanResolutionContext, Argument<B> beanType, Predicate<BeanDefinitionReference<B>> refPredicate, 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) Configures the context reading all bean definitions.voidregisterConfiguration(BeanConfiguration configuration) Registers a bean configuration.voidremoveBeanDefinition(RuntimeBeanDefinition<?> definition) The definition to remove.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.context.beans.BeanDefinitionService
getBeanDefinitions, getBeanDefinitions
-
Constructor Details
-
DefaultBeanDefinitionService
public DefaultBeanDefinitionService(@NonNull @NonNull BeanContextConfiguration contextConfiguration) Creates a new bean context with the given configuration.- Parameters:
contextConfiguration- The context configuration
-
-
Method Details
-
initialize
Configures the context reading all bean definitions.- Specified by:
initializein interfaceBeanDefinitionService- Parameters:
beanContext- the bean context
-
registerConfiguration
Description copied from interface:BeanDefinitionServiceRegisters a bean configuration.- Specified by:
registerConfigurationin interfaceBeanDefinitionService- Parameters:
configuration- the configuration to register
-
addBeanDefinition
Description copied from interface:BeanDefinitionServiceRegisters a runtime bean definition so it becomes visible to the provider alongside precompiled definitions.- Specified by:
addBeanDefinitionin interfaceBeanDefinitionService- Parameters:
definition- the runtime definition to register, never null
-
getBeanDefinitions
public <B> Iterable<BeanDefinition<B>> getBeanDefinitions(BeanContext beanContext, Argument<B> beanType, Predicate<BeanDefinitionReference<B>> refPredicate, Predicate<BeanDefinition<B>> defPredicate) Description copied from interface:BeanDefinitionServiceResolves enabled bean definitions.- Specified by:
getBeanDefinitionsin interfaceBeanDefinitionService- 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
-
getBeanReferences
Description copied from interface:BeanDefinitionServiceReturns all bean references.- Specified by:
getBeanReferencesin interfaceBeanDefinitionService- Returns:
- a list of all known bean definition references
-
getBeanDefinitions
public <B> Iterable<BeanDefinition<B>> getBeanDefinitions(BeanResolutionContext beanResolutionContext, Argument<B> beanType, Predicate<BeanDefinitionReference<B>> refPredicate, Predicate<BeanDefinition<B>> defPredicate) Description copied from interface:BeanDefinitionServiceResolves enabled bean definitions.- Specified by:
getBeanDefinitionsin interfaceBeanDefinitionService- 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
Description copied from interface:BeanDefinitionServiceReturns all enabled bean references.- Specified by:
getBeanReferencesin interfaceBeanDefinitionService- Parameters:
beanContext- the context for which references are requested- Returns:
- an iterable of bean definition references
-
reset
public void reset()Description copied from interface:BeanDefinitionServiceResets the provider by clearing internal caches and runtime registrations. Intended for container lifecycle management and test scenarios.- Specified by:
resetin interfaceBeanDefinitionService
-
removeBeanDefinition
The definition to remove.- Specified by:
removeBeanDefinitionin interfaceBeanDefinitionService- Parameters:
definition- The definition to remove
-
trackDisabled
Description copied from interface:BeanDefinitionServiceRecords that a qualified bean type has been disabled, along with human-readable reasons.- Specified by:
trackDisabledin interfaceBeanDefinitionService- Parameters:
beanType- the qualified bean type that has been disabledreasons- the reasons explaining why the bean is disabled
-
getEagerInitBeans
Description copied from interface:BeanDefinitionServiceReturns bean definitions that should be initialized eagerly.- Specified by:
getEagerInitBeansin interfaceBeanDefinitionService- Parameters:
beanContext- the bean context to eliminate disabled beans- Returns:
- an iterable of bean definitions that should be eagerly instantiated
-
getProcessedBeans
Description copied from interface:BeanDefinitionServiceReturns bean definitions that require contextual processing during startup.- Specified by:
getProcessedBeansin interfaceBeanDefinitionService- Parameters:
beanContext- the bean context to eliminate disabled beans- Returns:
- an iterable of bean definitions that require processing at startup
-
getParallelBeans
Description copied from interface:BeanDefinitionServiceReturns bean definitions that are safe to be instantiated in parallel during startup.- Specified by:
getParallelBeansin interfaceBeanDefinitionService- Parameters:
beanContext- the bean context to eliminate disabled beans- Returns:
- an iterable of bean definitions eligible for parallel creation
-
getTargetProxyBeans
Description copied from interface:BeanDefinitionServiceReturns target proxy bean definitions.- Specified by:
getTargetProxyBeansin interfaceBeanDefinitionService- Parameters:
beanContext- the bean context to eliminate disabled beans- Returns:
- an iterable of bean definitions that should be treated as target proxy candidates
-
getDisabledBeans
Description copied from interface:BeanDefinitionServiceReturns a disabled beans.- Specified by:
getDisabledBeansin interfaceBeanDefinitionService- Parameters:
beanContext- the bean context to eliminate disabled beans- Returns:
- a list of disabled beans with their associated reasons
-
exists
Description copied from interface:BeanDefinitionServiceReturns whether at least one bean definition exists for the given raw type. This is a lightweight existence check and does not consider qualifiers.- Specified by:
existsin interfaceBeanDefinitionService- Parameters:
beanType- the raw type to check- Returns:
- true if at least one definition of the given type is known; false otherwise
-