Package io.micronaut.security.aot
Class AOTContextUtils
java.lang.Object
io.micronaut.security.aot.AOTContextUtils
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 TypeMethodDescriptionstatic <T> boolean
containsBean
(Class<T> beanType, io.micronaut.context.Qualifier<T> qualifier, io.micronaut.aot.core.AOTContext aotContext) Return whether the bean of the given type is contained within this context.static <T> T
Obtains a Bean for the given type.static <T> T
getBean
(Class<T> beanType, io.micronaut.context.Qualifier<T> qualifier, io.micronaut.aot.core.AOTContext aotContext) Obtains a Bean for the given type and qualifier.static <T> Collection<T>
getBeansOfType
(Class<T> beanType, io.micronaut.aot.core.AOTContext aotContext) Get all beans of the given type.
-
Method Details
-
getBeansOfType
@NonNull public static <T> Collection<T> getBeansOfType(@NonNull Class<T> beanType, @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 typeaotContext
- The AOT Context- Returns:
- The found beans
-
getBean
@NonNull public static <T> T getBean(@NonNull Class<T> beanType, @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 typeaotContext
- The AOT Context- Returns:
- An instanceof said bean
- Throws:
io.micronaut.context.exceptions.NonUniqueBeanException
- When multiple possible bean definitions exist for the given typeio.micronaut.context.exceptions.NoSuchBeanException
- If the bean doesn't exist
-
containsBean
@NonNull public static <T> 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.- Type Parameters:
T
- The concrete type- Parameters:
beanType
- The bean typequalifier
- The qualifier for the beanaotContext
- The AOT Context- Returns:
- True if it is
-
getBean
@NonNull public 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.- Type Parameters:
T
- The bean type parameter- Parameters:
beanType
- The bean typequalifier
- The qualifieraotContext
- 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
-