Package io.micronaut.inject
Interface BeanDefinition<T>
- Type Parameters:
T- The bean type
- All Superinterfaces:
AnnotationMetadata,AnnotationMetadataDelegate,AnnotationMetadataProvider,AnnotationSource,ArgumentCoercible<T>,BeanContextConditional,BeanInfo<T>,BeanType<T>,Named,Ordered,QualifiedBeanType<T>
- All Known Subinterfaces:
DelegatingBeanDefinition<T>,DisposableBeanDefinition<T>,InitializingBeanDefinition<T>,InjectableBeanDefinition<T>,InstantiatableBeanDefinition<T>,ParametrizedInstantiatableBeanDefinition<T>,ProxyBeanDefinition<T>,RuntimeBeanDefinition<T>,ValidatedBeanDefinition<T>
- All Known Implementing Classes:
AbstractInitializableBeanDefinition,AbstractInitializableBeanDefinitionAndReference,AbstractProviderDefinition,ApplicationEventPublisherFactory,BeanProviderDefinition,DisabledBean,InterceptorRegistryBean,JakartaProviderBeanDefinition,JavaxProviderBeanDefinition
public interface BeanDefinition<T>
extends QualifiedBeanType<T>, Named, BeanType<T>, ArgumentCoercible<T>
Defines a bean definition and its requirements. A bean definition must have a singled injectable constructor or a
no-args constructor.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBERFields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTYFields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Method Summary
Modifier and TypeMethodDescriptiondefault <R> Optional<ExecutableMethod<T, R>> findMethod(String name, Class<?>... argumentTypes) Finds a singleExecutableMethodfor the given name and argument types.default <R> Stream<ExecutableMethod<T, R>> findPossibleMethods(String name) Finds possible methods for the given method name.default @NonNull StringgetBeanDescription(@NonNull TypeInformation.TypeFormat typeFormat) Gets a description of the bean as close as possible to source representation.default @NonNull StringgetBeanDescription(@NonNull TypeInformation.TypeFormat typeFormat, boolean includeArguments) Gets a description of the bean as close as possible to source representation.Returns the bean type.default ConstructorInjectionPoint<T> The single concrete constructor that is an injection point for creating the bean.IfBeanType.isContainerType()returns true this will return the container element.default @Nullable Class<?> Get the default implementation defined byDefaultImplementation.default Collection<ExecutableMethod<T, ?>> default Iterable<ExecutableMethod<T, ?>> WhenBeanType.requiresMethodProcessing()is true, this method returns the methods that require processing.default Collection<FieldInjectionPoint<T, ?>> All the fields that require injection.default Collection<MethodInjectionPoint<T, ?>> All methods that require injection.default @NonNull StringgetName()default Collection<MethodInjectionPoint<T, ?>> All the methods that should be called once the bean has been fully initialized and constructed.default Collection<MethodInjectionPoint<T, ?>> All the methods that should be called when the object is to be destroyed.default @Nullable ReplacesDefinition<T> The replacement defined byReplaces.default Collection<Class<?>> default <R> ExecutableMethod<T, R> getRequiredMethod(String name, Class<?>... argumentTypes) Finds a singleExecutableMethodfor the given name and argument types.default Optional<Class<? extends Annotation>> getScope()If the bean itself declares any type arguments this method will return the classes that represent those types.getTypeArguments(Class<?> type) Return the type arguments for the given interface or super type for this bean.getTypeArguments(String type) Return the type arguments for the given interface or super type for this bean.default @NonNull TypeInformation<T> default @NonNull Class<?>[]Returns the type parameters as a class array for the bean type.default @NonNull Class<?>[]getTypeParameters(@Nullable Class<?> type) Returns the type parameters as a class array for the given type.default booleanhasAnnotatedMethod(@NonNull Class<? extends Annotation> annotationClass, @NonNull String methodName, @NonNull Class<?>... argumentTypes) Whether anExecutableMethodexists which is annotated with the supplied annotationdefault booleandefault booleanDetermines if another bean definition can replace this bean definition.default booleanisCandidateBean(@Nullable Argument<?> beanType) Return whether this bean type is a candidate for dependency injection for the passed type.default booleandefault booleandefault booleanisProxy()Whether this bean definition represents a proxy.default booleanMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresentMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
booleanValue, 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.core.annotation.AnnotationMetadataProvider
getAnnotationMetadataMethods inherited from interface io.micronaut.inject.BeanContextConditional
isEnabled, isEnabledMethods inherited from interface io.micronaut.inject.BeanType
getBeanName, getExposedTypes, isContainerType, isPrimary, requiresMethodProcessingMethods inherited from interface io.micronaut.inject.QualifiedBeanType
getDeclaredQualifier, resolveDynamicQualifier
-
Method Details
-
getTypeInformation
- Returns:
- The type information for the bean.
- Since:
- 4.8.0
-
getScope
- Returns:
- The scope of the bean
-
getScopeName
- Returns:
- The name of the scope
-
isSingleton
default boolean isSingleton()- Returns:
- Whether the scope is singleton
-
getContainerElement
IfBeanType.isContainerType()returns true this will return the container element.- Returns:
- The container element.
-
isCandidateBean
Description copied from interface:BeanTypeReturn whether this bean type is a candidate for dependency injection for the passed type.- Specified by:
isCandidateBeanin interfaceBeanType<T>- Parameters:
beanType- The bean type- Returns:
- True if it is
-
isIterable
default boolean isIterable()- Returns:
- Whether the bean declared with
EachPropertyorEachBean
-
isConfigurationProperties
default boolean isConfigurationProperties()- Returns:
- Is the type configuration properties.
-
getBeanType
Description copied from interface:BeanTypeReturns the bean type.- Specified by:
getBeanTypein interfaceBeanInfo<T>- Specified by:
getBeanTypein interfaceBeanType<T>- Returns:
- The produced bean type
-
getDeclaringType
- Returns:
- The type that declares this definition, null if not applicable.
-
getConstructor
The single concrete constructor that is an injection point for creating the bean.- Returns:
- The constructor injection point
-
getRequiredComponents
- Returns:
- All required components for this entity definition
-
getInjectedMethods
All methods that require injection. This is a subset of all the methods in the class.- Returns:
- The required properties
-
getInjectedFields
All the fields that require injection.- Returns:
- The required fields
-
getPostConstructMethods
All the methods that should be called once the bean has been fully initialized and constructed.- Returns:
- Methods to call post construct
-
getPreDestroyMethods
All the methods that should be called when the object is to be destroyed.- Returns:
- Methods to call pre-destroy
-
getName
-
findMethod
Finds a singleExecutableMethodfor the given name and argument types.- Type Parameters:
R- The return type- Parameters:
name- The method nameargumentTypes- The argument types- Returns:
- An optional
ExecutableMethod
-
hasAnnotatedMethod
default boolean hasAnnotatedMethod(@NonNull Class<? extends Annotation> annotationClass, @NonNull String methodName, @NonNull Class<?>... argumentTypes) Whether anExecutableMethodexists which is annotated with the supplied annotation- Parameters:
methodName- The method nameargumentTypes- The argument types- Returns:
- Whether an
ExecutableMethodexists which is annotated with the supplied annotation - Since:
- 4.3.0
-
findPossibleMethods
Finds possible methods for the given method name.- Type Parameters:
R- The return type- Parameters:
name- The method name- Returns:
- The possible methods
-
getExecutableMethods
- Returns:
- The
ExecutableMethodinstances for this definition
-
asArgument
- Specified by:
asArgumentin interfaceArgumentCoercible<T>- Specified by:
asArgumentin interfaceBeanInfo<T>- Returns:
- The argument
-
isProxy
default boolean isProxy()Whether this bean definition represents a proxy.- Returns:
- True if it represents a proxy
-
getTypeArguments
If the bean itself declares any type arguments this method will return the classes that represent those types.- Returns:
- The type arguments
-
getTypeArguments
Return the type arguments for the given interface or super type for this bean.- Parameters:
type- The super class or interface type- Returns:
- The type arguments
-
getTypeParameters
Returns the type parameters as a class array for the given type.- Parameters:
type- The type- Returns:
- The type parameters
-
getTypeParameters
Returns the type parameters as a class array for the bean type.- Returns:
- The type parameters for the bean type as a class array.
-
getTypeArguments
Return the type arguments for the given interface or super type for this bean.- Parameters:
type- The super class or interface type- Returns:
- The type arguments
-
getRequiredMethod
Finds a singleExecutableMethodfor the given name and argument types.- Type Parameters:
R- The return type- Parameters:
name- The method nameargumentTypes- The argument types- Returns:
- An optional
ExecutableMethod - Throws:
IllegalStateException- If the method cannot be found
-
isAbstract
default boolean isAbstract()- Returns:
- Whether the bean definition is abstract
-
getGenericBeanType
- Specified by:
getGenericBeanTypein interfaceBeanInfo<T>- Returns:
- The generic bean type
-
getBeanDescription
default @NonNull String getBeanDescription(@NonNull TypeInformation.TypeFormat typeFormat, boolean includeArguments) Gets a description of the bean as close as possible to source representation.- Parameters:
typeFormat- The type format to use.includeArguments- Whether to include arguments.- Returns:
- The bean description.
- Since:
- 4.8.0
-
getBeanDescription
Gets a description of the bean as close as possible to source representation.- Parameters:
typeFormat- The type format to use.- Returns:
- The bean description.
- Since:
- 4.8.0
-
getDefaultImplementation
Get the default implementation defined byDefaultImplementation.- Returns:
- The default implementation
- Since:
- 5.0
-
isCanBeReplaced
default boolean isCanBeReplaced()Determines if another bean definition can replace this bean definition. Some bean definitions are not replaceable. SeeInfrastructure.- Returns:
- true if it can be replaced
- Since:
- 5.0
-
getReplacesDefinition
The replacement defined byReplaces.- Returns:
- The bean replacement definition if present, otherwise null.
- Since:
- 5.0
-
getExecutableMethodsForProcessing
WhenBeanType.requiresMethodProcessing()is true, this method returns the methods that require processing. Executable methods withExecutable.processOnStartup()set to true.- Returns:
- The methods that require processing.
- Since:
- 5.0
- See Also:
-