Package io.micronaut.inject.provider
Class AbstractProviderDefinition<T>
- java.lang.Object
-
- io.micronaut.inject.provider.AbstractProviderDefinition<T>
-
- Type Parameters:
T- The generic type
- All Implemented Interfaces:
io.micronaut.core.annotation.AnnotationMetadata,io.micronaut.core.annotation.AnnotationMetadataDelegate,io.micronaut.core.annotation.AnnotationMetadataProvider,io.micronaut.core.annotation.AnnotationSource,io.micronaut.core.naming.Named,io.micronaut.core.type.ArgumentCoercible<T>,BeanContextConditional,BeanDefinition<T>,BeanDefinitionReference<T>,BeanFactory<T>,BeanType<T>
- Direct Known Subclasses:
BeanProviderDefinition,JakartaProviderBeanDefinition,JavaxProviderBeanDefinition
public abstract class AbstractProviderDefinition<T> extends java.lang.Object implements BeanDefinition<T>, BeanFactory<T>, BeanDefinitionReference<T>
Abstract bean definition for other providers to extend from.- Since:
- 3.0.0
-
-
Field Summary
-
Fields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
-
Fields inherited from interface io.micronaut.inject.BeanDefinition
NAMED_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description AbstractProviderDefinition()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tbuild(BeanResolutionContext resolutionContext, BeanContext context, BeanDefinition<T> definition)Builds a bean instance.protected abstract TbuildProvider(BeanResolutionContext resolutionContext, BeanContext context, io.micronaut.core.type.Argument<java.lang.Object> argument, Qualifier<java.lang.Object> qualifier, boolean singleton)Builds a provider implementation.booleanequals(java.lang.Object o)io.micronaut.core.annotation.AnnotationMetadatagetAnnotationMetadata()java.lang.StringgetBeanDefinitionName()Qualifier<T>getDeclaredQualifier()Resolve the declared qualifier for this bean.java.util.List<io.micronaut.core.type.Argument<?>>getTypeArguments()If the bean itself declares any type arguments this method will return the classes that represent those types.java.util.List<io.micronaut.core.type.Argument<?>>getTypeArguments(java.lang.Class<?> type)Return the type arguments for the given interface or super type for this bean.inthashCode()booleanisAbstract()protected booleanisAllowEmptyProviders(BeanContext context)Return whether missing providers are allowed for this implementation.booleanisContainerType()Checks whether the bean type is a container type.booleanisEnabled(BeanContext context, BeanResolutionContext resolutionContext)Return whether this component is enabled for the given context.booleanisPresent()booleanisSingleton()BeanDefinition<T>load()Loads the bean definition.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
getAnnotationValuesByName, getAnnotationValuesByStereotype, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, 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, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, 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.inject.BeanContextConditional
isEnabled
-
Methods inherited from interface io.micronaut.inject.BeanDefinition
asArgument, findMethod, findPossibleMethods, getBeanType, getConstructor, getContainerElement, getDeclaringType, getExecutableMethods, getInjectedFields, getInjectedMethods, getName, getPostConstructMethods, getPreDestroyMethods, getRequiredComponents, getRequiredMethod, getScope, getScopeName, getTypeArguments, getTypeParameters, getTypeParameters, inject, inject, isCandidateBean, isIterable, isProvided, isProxy, resolveDynamicQualifier
-
Methods inherited from interface io.micronaut.inject.BeanDefinitionReference
isConfigurationProperties, isContextScope, load
-
Methods inherited from interface io.micronaut.inject.BeanFactory
build
-
Methods inherited from interface io.micronaut.inject.BeanType
getExposedTypes, getName, isPrimary, requiresMethodProcessing
-
-
-
-
Method Detail
-
isContainerType
public boolean isContainerType()
Description copied from interface:BeanTypeChecks whether the bean type is a container type.- Specified by:
isContainerTypein interfaceBeanType<T>- Returns:
- Whether the type is a container type like
Iterable.
-
isEnabled
public boolean isEnabled(@NonNull BeanContext context, @Nullable BeanResolutionContext resolutionContext)Description copied from interface:BeanContextConditionalReturn whether this component is enabled for the given context.- Specified by:
isEnabledin interfaceBeanContextConditional- Parameters:
context- The contextresolutionContext- The bean resolution context- Returns:
- True if it is
-
getBeanDefinitionName
public java.lang.String getBeanDefinitionName()
- Specified by:
getBeanDefinitionNamein interfaceBeanDefinitionReference<T>- Returns:
- The class name of the backing
BeanDefinition
-
load
public BeanDefinition<T> load()
Description copied from interface:BeanDefinitionReferenceLoads the bean definition.- Specified by:
loadin interfaceBeanDefinitionReference<T>- Returns:
- The loaded component definition or null if it shouldn't be loaded
-
isPresent
public boolean isPresent()
- Specified by:
isPresentin interfaceBeanDefinitionReference<T>- Returns:
- Is the underlying bean type present on the classpath
-
buildProvider
@NonNull protected abstract T buildProvider(@NonNull BeanResolutionContext resolutionContext, @NonNull BeanContext context, @NonNull io.micronaut.core.type.Argument<java.lang.Object> argument, @Nullable Qualifier<java.lang.Object> qualifier, boolean singleton)
Builds a provider implementation.- Parameters:
resolutionContext- The resolution contextcontext- The contextargument- The argumentqualifier- The qualifiersingleton- Whether the bean is a singleton- Returns:
- The provider
-
build
public T build(BeanResolutionContext resolutionContext, BeanContext context, BeanDefinition<T> definition) throws BeanInstantiationException
Description copied from interface:BeanFactoryBuilds a bean instance.- Specified by:
buildin interfaceBeanFactory<T>- Parameters:
resolutionContext- The bean resolution contextcontext- The contextdefinition- The definition- Returns:
- The instance
- Throws:
BeanInstantiationException- if the instance could not be instantiated
-
isAllowEmptyProviders
protected boolean isAllowEmptyProviders(BeanContext context)
Return whether missing providers are allowed for this implementation. IffalseaNoSuchBeanExceptionis thrown.- Parameters:
context- The context- Returns:
- Returns
trueif missing providers are allowed
-
isAbstract
public final boolean isAbstract()
- Specified by:
isAbstractin interfaceBeanDefinition<T>- Returns:
- Whether the bean definition is abstract
-
isSingleton
public final boolean isSingleton()
- Specified by:
isSingletonin interfaceBeanDefinition<T>- Specified by:
isSingletonin interfaceBeanDefinitionReference<T>- Returns:
- Whether the scope is singleton
-
getTypeArguments
@NonNull public final java.util.List<io.micronaut.core.type.Argument<?>> getTypeArguments(java.lang.Class<?> type)
Description copied from interface:BeanDefinitionReturn the type arguments for the given interface or super type for this bean.- Specified by:
getTypeArgumentsin interfaceBeanDefinition<T>- Parameters:
type- The super class or interface type- Returns:
- The type arguments
-
getTypeArguments
@NonNull public final java.util.List<io.micronaut.core.type.Argument<?>> getTypeArguments()
Description copied from interface:BeanDefinitionIf the bean itself declares any type arguments this method will return the classes that represent those types.- Specified by:
getTypeArgumentsin interfaceBeanDefinition<T>- Returns:
- The type arguments
-
getAnnotationMetadata
public io.micronaut.core.annotation.AnnotationMetadata getAnnotationMetadata()
- Specified by:
getAnnotationMetadatain interfaceio.micronaut.core.annotation.AnnotationMetadataProvider
-
getDeclaredQualifier
public Qualifier<T> getDeclaredQualifier()
Description copied from interface:BeanDefinitionResolve the declared qualifier for this bean.- Specified by:
getDeclaredQualifierin interfaceBeanDefinition<T>- Returns:
- The qualifier or null if this isn't one
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-