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
,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
,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_MEMBER
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R> Optional<ExecutableMethod<T,
R>> findMethod
(String name, Class<?>... argumentTypes) Finds a singleExecutableMethod
for the given name and argument types.default <R> Stream<ExecutableMethod<T,
R>> findPossibleMethods
(String name) Finds possible methods for the given method name.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.Resolve the declared qualifier for this bean.default Collection<ExecutableMethod<T,
?>> default Collection<FieldInjectionPoint<T,
?>> All the fields that require injection.default Collection<MethodInjectionPoint<T,
?>> All methods that require injection.getName()
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 Collection<Class<?>>
default <R> ExecutableMethod<T,
R> getRequiredMethod
(String name, Class<?>... argumentTypes) Finds a singleExecutableMethod
for 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.Returns the type parameters as a class array for the bean type.getTypeParameters
(@Nullable Class<?> type) Returns the type parameters as a class array for the given type.default boolean
default boolean
isCandidateBean
(@Nullable Argument<?> beanType) Return whether this bean type is a candidate for dependency injection for the passed type.default boolean
default boolean
default boolean
isProxy()
Whether this bean definition represents a proxy.default boolean
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresent
Methods 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, synthesizeDeclaredAnnotationsByType
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
getAnnotationMetadata
Methods inherited from interface io.micronaut.inject.BeanContextConditional
isEnabled, isEnabled
Methods inherited from interface io.micronaut.inject.BeanType
getBeanName, getExposedTypes, isContainerType, isPrimary, requiresMethodProcessing
-
Method Details
-
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:BeanType
Return whether this bean type is a candidate for dependency injection for the passed type.- Specified by:
isCandidateBean
in interfaceBeanType<T>
- Parameters:
beanType
- The bean type- Returns:
- True if it is
-
isIterable
default boolean isIterable()- Returns:
- Whether the bean declared with
EachProperty
orEachBean
-
isConfigurationProperties
default boolean isConfigurationProperties()- Returns:
- Is the type configuration properties.
-
getBeanType
Description copied from interface:BeanType
Returns the bean type.- Specified by:
getBeanType
in interfaceBeanInfo<T>
- Specified by:
getBeanType
in 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 singleExecutableMethod
for the given name and argument types.- Type Parameters:
R
- The return type- Parameters:
name
- The method nameargumentTypes
- The argument types- Returns:
- An optional
ExecutableMethod
-
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
ExecutableMethod
instances for this definition
-
asArgument
- Specified by:
asArgument
in interfaceArgumentCoercible<T>
- Specified by:
asArgument
in 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 singleExecutableMethod
for 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:
getGenericBeanType
in interfaceBeanInfo<T>
- Returns:
- The generic bean type
-
getDeclaredQualifier
Resolve the declared qualifier for this bean.- Specified by:
getDeclaredQualifier
in interfaceQualifiedBeanType<T>
- Returns:
- The qualifier or null if this isn't one
-
resolveDynamicQualifier
- Specified by:
resolveDynamicQualifier
in interfaceQualifiedBeanType<T>
- Returns:
- Method that can be overridden to resolve a dynamic qualifier
-