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.beans.BeanInfo<T>, io.micronaut.core.naming.Named, io.micronaut.core.order.Ordered, io.micronaut.core.type.ArgumentCoercible<T>, BeanContextConditional, BeanDefinition<T>, BeanDefinitionReference<T>, BeanType<T>, InstantiatableBeanDefinition<T>, QualifiedBeanType<T>
Direct Known Subclasses:
BeanProviderDefinition, JakartaProviderBeanDefinition, JavaxProviderBeanDefinition

public abstract class AbstractProviderDefinition<T> extends Object implements InstantiatableBeanDefinition<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.core.annotation.AnnotationSource

    EMPTY

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract T
    buildProvider(@NonNull BeanResolutionContext resolutionContext, @NonNull BeanContext context, @NonNull io.micronaut.core.type.Argument<Object> argument, @Nullable Qualifier<Object> qualifier, boolean singleton)
    Builds a provider implementation.
    boolean
     
    io.micronaut.core.annotation.AnnotationMetadata
     
     
    Resolve the declared qualifier for this bean.
    final @NonNull List<io.micronaut.core.type.Argument<?>>
    If the bean itself declares any type arguments this method will return the classes that represent those types.
    final @NonNull List<io.micronaut.core.type.Argument<?>>
    Return the type arguments for the given interface or super type for this bean.
    int
     
    instantiate(BeanResolutionContext resolutionContext, BeanContext context)
    Builds a bean instance.
    final boolean
     
    protected boolean
    Return whether missing providers are allowed for this implementation.
    boolean
    isCandidateBean(io.micronaut.core.type.Argument<?> beanType)
    Return whether this bean type is a candidate for dependency injection for the passed type.
    boolean
     
    boolean
    Checks whether the bean type is a container type.
    boolean
    isEnabled(@NonNull BeanContext context, @Nullable BeanResolutionContext resolutionContext)
    Return whether this component is enabled for the given context.
    boolean
     
    final boolean
     
    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

    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.inject.BeanContextConditional

    isEnabled

    Methods inherited from interface io.micronaut.inject.BeanDefinitionReference

    isContextScope, isProxiedBean, isProxyTarget, load

    Methods inherited from interface io.micronaut.core.beans.BeanInfo

    getOrder

    Methods inherited from interface io.micronaut.inject.BeanType

    getBeanName, getExposedTypes, isPrimary, requiresMethodProcessing

    Methods inherited from interface io.micronaut.inject.InstantiatableBeanDefinition

    instantiate
  • Constructor Details

    • AbstractProviderDefinition

      public AbstractProviderDefinition()
  • Method Details

    • isContainerType

      public boolean isContainerType()
      Description copied from interface: BeanType
      Checks whether the bean type is a container type.
      Specified by:
      isContainerType in interface BeanType<T>
      Returns:
      Whether the type is a container type like Iterable.
    • isCandidateBean

      public boolean isCandidateBean(io.micronaut.core.type.Argument<?> beanType)
      Description copied from interface: BeanType
      Return whether this bean type is a candidate for dependency injection for the passed type.
      Specified by:
      isCandidateBean in interface BeanDefinition<T>
      Specified by:
      isCandidateBean in interface BeanType<T>
      Parameters:
      beanType - The bean type
      Returns:
      True if it is
    • isEnabled

      public boolean isEnabled(@NonNull @NonNull BeanContext context, @Nullable @Nullable BeanResolutionContext resolutionContext)
      Description copied from interface: BeanContextConditional
      Return whether this component is enabled for the given context.
      Specified by:
      isEnabled in interface BeanContextConditional
      Parameters:
      context - The context
      resolutionContext - The bean resolution context
      Returns:
      True if it is
    • getBeanDefinitionName

      public String getBeanDefinitionName()
      Specified by:
      getBeanDefinitionName in interface BeanDefinitionReference<T>
      Returns:
      The class name of the backing BeanDefinition
    • load

      public BeanDefinition<T> load()
      Description copied from interface: BeanDefinitionReference
      Loads the bean definition.
      Specified by:
      load in interface BeanDefinitionReference<T>
      Returns:
      The loaded component definition or null if it shouldn't be loaded
    • isPresent

      public boolean isPresent()
      Specified by:
      isPresent in interface BeanDefinitionReference<T>
      Returns:
      Is the underlying bean type present on the classpath
    • buildProvider

      @NonNull protected abstract T buildProvider(@NonNull @NonNull BeanResolutionContext resolutionContext, @NonNull @NonNull BeanContext context, @NonNull @NonNull io.micronaut.core.type.Argument<Object> argument, @Nullable @Nullable Qualifier<Object> qualifier, boolean singleton)
      Builds a provider implementation.
      Parameters:
      resolutionContext - The resolution context
      context - The context
      argument - The argument
      qualifier - The qualifier
      singleton - Whether the bean is a singleton
      Returns:
      The provider
    • instantiate

      public T instantiate(BeanResolutionContext resolutionContext, BeanContext context) throws BeanInstantiationException
      Description copied from interface: InstantiatableBeanDefinition
      Builds a bean instance.
      Specified by:
      instantiate in interface InstantiatableBeanDefinition<T>
      Parameters:
      resolutionContext - The bean resolution context
      context - The context
      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. If false a NoSuchBeanException is thrown.
      Parameters:
      context - The context
      Returns:
      Returns true if missing providers are allowed
    • isAbstract

      public final boolean isAbstract()
      Specified by:
      isAbstract in interface BeanDefinition<T>
      Returns:
      Whether the bean definition is abstract
    • isSingleton

      public final boolean isSingleton()
      Specified by:
      isSingleton in interface BeanDefinition<T>
      Specified by:
      isSingleton in interface BeanDefinitionReference<T>
      Returns:
      Whether the scope is singleton
    • isConfigurationProperties

      public boolean isConfigurationProperties()
      Specified by:
      isConfigurationProperties in interface BeanDefinition<T>
      Specified by:
      isConfigurationProperties in interface BeanDefinitionReference<T>
      Returns:
      Is the type configuration properties.
    • getTypeArguments

      @NonNull public final @NonNull List<io.micronaut.core.type.Argument<?>> getTypeArguments(Class<?> type)
      Description copied from interface: BeanDefinition
      Return the type arguments for the given interface or super type for this bean.
      Specified by:
      getTypeArguments in interface BeanDefinition<T>
      Parameters:
      type - The super class or interface type
      Returns:
      The type arguments
    • getTypeArguments

      @NonNull public final @NonNull List<io.micronaut.core.type.Argument<?>> getTypeArguments()
      Description copied from interface: BeanDefinition
      If the bean itself declares any type arguments this method will return the classes that represent those types.
      Specified by:
      getTypeArguments in interface BeanDefinition<T>
      Returns:
      The type arguments
    • getAnnotationMetadata

      public io.micronaut.core.annotation.AnnotationMetadata getAnnotationMetadata()
      Specified by:
      getAnnotationMetadata in interface io.micronaut.core.annotation.AnnotationMetadataProvider
    • getDeclaredQualifier

      public Qualifier<T> getDeclaredQualifier()
      Description copied from interface: BeanDefinition
      Resolve the declared qualifier for this bean.
      Specified by:
      getDeclaredQualifier in interface BeanDefinition<T>
      Specified by:
      getDeclaredQualifier in interface QualifiedBeanType<T>
      Returns:
      The qualifier or null if this isn't one
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object