Class AOTContextUtils

java.lang.Object
io.micronaut.security.aot.AOTContextUtils

@Internal public final class AOTContextUtils extends Object
Utility to retrieve beans from the Application Context associated to the AOT Context.
Since:
3.9.0
Author:
Sergio del Amo
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> @io.micronaut.core.annotation.NonNull boolean
    containsBean(@NonNull Class<T> beanType, @Nullable io.micronaut.context.Qualifier<T> qualifier, @NonNull io.micronaut.aot.core.AOTContext aotContext)
    Return whether the bean of the given type is contained within this context.
    static <T> T
    getBean(@NonNull Class<T> beanType, @NonNull io.micronaut.aot.core.AOTContext aotContext)
    Obtains a Bean for the given type.
    static <T> T
    getBean(@NonNull Class<T> beanType, @Nullable io.micronaut.context.Qualifier<T> qualifier, @NonNull io.micronaut.aot.core.AOTContext aotContext)
    Obtains a Bean for the given type and qualifier.
    static <T> @NonNull Collection<T>
    getBeansOfType(@NonNull Class<T> beanType, @NonNull io.micronaut.aot.core.AOTContext aotContext)
    Get all beans of the given type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getBeansOfType

      @NonNull public static <T> @NonNull Collection<T> getBeansOfType(@NonNull @NonNull Class<T> beanType, @NonNull @NonNull io.micronaut.aot.core.AOTContext aotContext)
      Get all beans of the given type.
      Type Parameters:
      T - The bean type parameter
      Parameters:
      beanType - The bean type
      aotContext - The AOT Context
      Returns:
      The found beans
    • getBean

      @NonNull public static <T> T getBean(@NonNull @NonNull Class<T> beanType, @NonNull @NonNull io.micronaut.aot.core.AOTContext aotContext)
      Obtains a Bean for the given type.
      Type Parameters:
      T - The bean type parameter
      Parameters:
      beanType - The bean type
      aotContext - The AOT Context
      Returns:
      An instanceof said bean
      Throws:
      io.micronaut.context.exceptions.NonUniqueBeanException - When multiple possible bean definitions exist for the given type
      io.micronaut.context.exceptions.NoSuchBeanException - If the bean doesn't exist
    • containsBean

      @NonNull public static <T> @io.micronaut.core.annotation.NonNull boolean containsBean(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable io.micronaut.context.Qualifier<T> qualifier, @NonNull @NonNull io.micronaut.aot.core.AOTContext aotContext)
      Return whether the bean of the given type is contained within this context.
      Type Parameters:
      T - The concrete type
      Parameters:
      beanType - The bean type
      qualifier - The qualifier for the bean
      aotContext - The AOT Context
      Returns:
      True if it is
    • getBean

      @NonNull public static <T> T getBean(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable io.micronaut.context.Qualifier<T> qualifier, @NonNull @NonNull io.micronaut.aot.core.AOTContext aotContext)
      Obtains a Bean for the given type and qualifier.
      Type Parameters:
      T - The bean type parameter
      Parameters:
      beanType - The bean type
      qualifier - The qualifier
      aotContext - The AOT Context
      Returns:
      An instanceof said bean
      Throws:
      io.micronaut.context.exceptions.NonUniqueBeanException - When multiple possible bean definitions exist for the given type
      See Also:
      • Qualifiers