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> @io.micronaut.core.annotation.NonNull booleancontainsBean(@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> TObtains a Bean for the given type.static <T> TgetBean(@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.
-
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 typeaotContext- 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 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> @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 typequalifier- The qualifier for the beanaotContext- 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 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
-