Package io.micronaut.context
Interface RuntimeBeanDefinition<T>
- Type Parameters:
- T- The bean type
- All Superinterfaces:
- AnnotationMetadata,- AnnotationMetadataDelegate,- AnnotationMetadataProvider,- AnnotationSource,- ArgumentCoercible<T>,- BeanContextConditional,- BeanDefinition<T>,- BeanDefinitionReference<T>,- BeanInfo<T>,- BeanType<T>,- InstantiatableBeanDefinition<T>,- Named,- Ordered,- QualifiedBeanType<T>
public interface RuntimeBeanDefinition<T>
extends BeanDefinitionReference<T>, InstantiatableBeanDefinition<T>, BeanContextConditional
Allow the construction for bean definitions programmatically that can be registered
 via 
BeanDefinitionRegistry at runtime.
 This differs from BeanDefinitionRegistry.registerSingleton(Object) in that
 beans registered this way can be created lazily or not at all and participate
 more completely in the life cycle of the BeanContext (for examples event listeners like BeanCreatedEventListener will be fired).
Note that it is generally not recommended to use this approach and build time bean computation is preferred. This type is designed to support a few limited use cases where runtime bean registration is required.
- Since:
- 3.6.0
- Author:
- graemerocher
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA builder for constructingRuntimeBeanDefinitioninstances.
- 
Field SummaryFields inherited from interface io.micronaut.core.annotation.AnnotationMetadataCLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBERFields inherited from interface io.micronaut.core.annotation.AnnotationSourceEMPTYFields inherited from interface io.micronaut.core.order.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Method SummaryModifier and TypeMethodDescriptionstatic <B> @NonNull RuntimeBeanDefinition.Builder<B>A new builder for constructing and configuring runtime created beans.static <B> @NonNull RuntimeBeanDefinition.Builder<B>A new builder for constructing and configuring runtime created beans.static <B> @NonNull RuntimeBeanDefinition.Builder<B>builder(B bean) A new builder for constructing and configuring runtime created beans.default @NonNull AnnotationMetadataSupplies the metadata.default StringgetTypeArguments(Class<?> type) Return the type arguments for the given interface or super type for this bean.default booleandefault booleandefault booleanisEnabled(@NonNull BeanContext context, BeanResolutionContext resolutionContext) Return whether this component is enabled for the given context.default booleandefault booleandefault BeanDefinition<T>load()Loads the bean definition.default BeanDefinition<T>load(BeanContext context) Loads the bean definition for the currentBeanContext.static <B> @NonNull RuntimeBeanDefinition<B>Creates a new bean definition that will resolve the bean from the given supplier.static <B> @NonNull RuntimeBeanDefinition<B>of(B bean) Creates a new effectively singleton bean definition that references the given bean.Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataenumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresentMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegatebooleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, copyAnnotationMetadata, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByName, getAnnotationValuesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByName, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getTargetAnnotationMetadata, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasPropertyExpressions, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByTypeMethods inherited from interface io.micronaut.inject.BeanContextConditionalisEnabledMethods inherited from interface io.micronaut.inject.BeanDefinitionasArgument, findMethod, findPossibleMethods, getBeanDescription, getBeanDescription, getBeanType, getConstructor, getContainerElement, getDeclaredQualifier, getDeclaringType, getExecutableMethods, getGenericBeanType, getInjectedFields, getInjectedMethods, getName, getPostConstructMethods, getPreDestroyMethods, getRequiredComponents, getRequiredMethod, getScope, getScopeName, getTypeArguments, getTypeArguments, getTypeInformation, getTypeParameters, getTypeParameters, hasAnnotatedMethod, isAbstract, isCandidateBean, isIterable, isProxy, resolveDynamicQualifierMethods inherited from interface io.micronaut.inject.BeanDefinitionReferenceisProxiedBean, isProxyTargetMethods inherited from interface io.micronaut.inject.BeanTypegetBeanName, getExposedTypes, isContainerType, isPrimary, requiresMethodProcessingMethods inherited from interface io.micronaut.inject.InstantiatableBeanDefinitioninstantiate, instantiate
- 
Method Details- 
getAnnotationMetadataDescription copied from interface:AnnotationMetadataProviderSupplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA.- Specified by:
- getAnnotationMetadatain interface- AnnotationMetadataProvider
- Returns:
- The AnnotationMetadata
 
- 
isEnableddefault boolean isEnabled(@NonNull @NonNull BeanContext context, BeanResolutionContext resolutionContext) Description copied from interface:BeanContextConditionalReturn whether this component is enabled for the given context.- Specified by:
- isEnabledin interface- BeanContextConditional
- Parameters:
- context- The context
- resolutionContext- The bean resolution context
- Returns:
- True if it is
 
- 
getTypeArgumentsDescription copied from interface:BeanDefinitionReturn the type arguments for the given interface or super type for this bean.- Specified by:
- getTypeArgumentsin interface- BeanDefinition<T>
- Parameters:
- type- The super class or interface type
- Returns:
- The type arguments
 
- 
isContextScopedefault boolean isContextScope()- Specified by:
- isContextScopein interface- BeanDefinitionReference<T>
- Returns:
- Is this class context scope
 
- 
isConfigurationPropertiesdefault boolean isConfigurationProperties()- Specified by:
- isConfigurationPropertiesin interface- BeanDefinition<T>
- Specified by:
- isConfigurationPropertiesin interface- BeanDefinitionReference<T>
- Returns:
- Is this bean a configuration properties.
 
- 
loadDescription copied from interface:BeanDefinitionReferenceLoads the bean definition.- Specified by:
- loadin interface- BeanDefinitionReference<T>
- Returns:
- The loaded component definition or null if it shouldn't be loaded
 
- 
getBeanDefinitionName- Specified by:
- getBeanDefinitionNamein interface- BeanDefinitionReference<T>
- Returns:
- The class name of the backing BeanDefinition
 
- 
loadDescription copied from interface:BeanDefinitionReferenceLoads the bean definition for the currentBeanContext.- Specified by:
- loadin interface- BeanDefinitionReference<T>
- Parameters:
- context- The bean context
- Returns:
- The loaded bean definition or null if it shouldn't be loaded
 
- 
isPresentdefault boolean isPresent()- Specified by:
- isPresentin interface- BeanDefinitionReference<T>
- Returns:
- Is the underlying bean type present on the classpath
 
- 
isSingletondefault boolean isSingleton()- Specified by:
- isSingletonin interface- BeanDefinition<T>
- Specified by:
- isSingletonin interface- BeanDefinitionReference<T>
- Returns:
- Is this bean a singleton.
 
- 
ofCreates a new effectively singleton bean definition that references the given bean.- Type Parameters:
- B- The bean type
- Parameters:
- bean- The bean
- Returns:
- The BeanDefinitionReference
- Since:
- 3.6.0
 
- 
of@NonNull static <B> @NonNull RuntimeBeanDefinition<B> of(@NonNull @NonNull Class<B> beanType, @NonNull @NonNull Supplier<B> beanSupplier) Creates a new bean definition that will resolve the bean from the given supplier.The bean is by default not singleton and the supplier will be invoked for each injection point. - Type Parameters:
- B- The bean type
- Parameters:
- beanType- The bean type
- beanSupplier- The bean supplier
- Returns:
- The BeanDefinitionReference
- Since:
- 3.6.0
 
- 
builderA new builder for constructing and configuring runtime created beans.- Type Parameters:
- B- The bean type
- Parameters:
- bean- The bean to use
- Returns:
- The builder
 
- 
builder@NonNull static <B> @NonNull RuntimeBeanDefinition.Builder<B> builder(@NonNull @NonNull Class<B> beanType, @NonNull @NonNull Supplier<B> beanSupplier) A new builder for constructing and configuring runtime created beans.- Type Parameters:
- B- The bean type
- Parameters:
- beanType- The bean type
- beanSupplier- The bean supplier
- Returns:
- The builder
 
- 
builder@NonNull static <B> @NonNull RuntimeBeanDefinition.Builder<B> builder(@NonNull @NonNull Argument<B> beanType, @NonNull @NonNull Supplier<B> beanSupplier) A new builder for constructing and configuring runtime created beans.- Type Parameters:
- B- The bean type
- Parameters:
- beanType- The bean type
- beanSupplier- The bean supplier
- Returns:
- The builder
 
 
-