Package io.micronaut.context
Class AbstractBeanResolutionContext
java.lang.Object
io.micronaut.context.AbstractBeanResolutionContext
- All Implemented Interfaces:
BeanResolutionContext
,ValueResolver<CharSequence>
,AutoCloseable
- Direct Known Subclasses:
DefaultBeanResolutionContext
@Internal
public abstract class AbstractBeanResolutionContext
extends Object
implements BeanResolutionContext
Default implementation of the
BeanResolutionContext
interface.- Since:
- 1.2.3
- Author:
- Graeme Rocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A segment that represents annotation.static class
A segment that represents a method argument.static class
A segment that represents a constructor.static class
A segment that represents a field.static class
A segment that represents a method argument.static class
A segment that represents a method.Nested classes/interfaces inherited from interface io.micronaut.context.BeanResolutionContext
BeanResolutionContext.Path, BeanResolutionContext.Segment<B,
T> -
Field Summary
Modifier and TypeFieldDescriptionprotected final DefaultBeanContext
protected final BeanResolutionContext.Path
protected final BeanDefinition<?>
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractBeanResolutionContext
(DefaultBeanContext context, BeanDefinition<?> rootDefinition) -
Method Summary
Modifier and TypeMethodDescription<T> void
addDependentBean
(BeanRegistration<T> beanRegistration) Adds a dependent bean to the resolution context.void
Copy the state from a previous resolution context.void
Call back to destroy anyInjectScope
beans.Find an optional bean of the given type and qualifier.<T> Optional<T>
get
(CharSequence name, ArgumentConversionContext<T> conversionContext) Resolve the given property for the given name.<T> Optional<T>
get
(CharSequence name, Class<T> requiredType) Resolve the given property for the given name.final Object
getAttribute
(CharSequence key) Get the map representing current attributes.<T> T
Get a bean of the given type and qualifier.<T> @NonNull Collection<BeanRegistration<T>>
getBeanRegistrations
(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Obtains the bean registrations for the given type and qualifier.<T> @NonNull Collection<T>
getBeansOfType
(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Get all beans of the given type and qualifier.final BeanContext
getPath()
final BeanDefinition
Obtains a map of beans of the given type and qualifier.void
Marks first dependent as factory.protected void
onNewSegment
(BeanResolutionContext.Segment<?, ?> segment) List<BeanRegistration<?>>
void
pushDependentBeans
(List<BeanRegistration<?>> dependentBeans) The push the current dependent beans that must be destroyed by an upstream bean.final Object
Remove the attribute for the given key.final Object
setAttribute
(CharSequence key, Object value) Store a value within the context.void
setAttributes
(Map<CharSequence, Object> attributes) Set new attributes map (The map is supposed to be mutable).setConfigurationPath
(ConfigurationPath configurationPath) Sets the configuration path.void
setCurrentQualifier
(@Nullable Qualifier<?> qualifier) Sets the current qualifier.streamOfType
(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Obtains a stream of beans of the given type and qualifier.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.context.BeanResolutionContext
addInFlightBean, close, copy, getInFlightBean, removeInFlightBean
Methods inherited from interface io.micronaut.core.value.ValueResolver
get, get
-
Field Details
-
context
-
rootDefinition
-
path
-
-
Constructor Details
-
AbstractBeanResolutionContext
@Internal protected AbstractBeanResolutionContext(DefaultBeanContext context, BeanDefinition<?> rootDefinition) - Parameters:
context
- The bean contextrootDefinition
- The bean root definition
-
-
Method Details
-
getConfigurationPath
- Specified by:
getConfigurationPath
in interfaceBeanResolutionContext
- Returns:
- The configuration path.
-
setConfigurationPath
Description copied from interface:BeanResolutionContext
Sets the configuration path.- Specified by:
setConfigurationPath
in interfaceBeanResolutionContext
- Parameters:
configurationPath
- The configuration path.- Returns:
- The previous path
-
getBean
@NonNull public <T> T getBean(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanResolutionContext
Get a bean of the given type and qualifier.- Specified by:
getBean
in interfaceBeanResolutionContext
- Type Parameters:
T
- The bean type parameter- Parameters:
beanType
- The bean typequalifier
- The qualifier- Returns:
- The found bean
-
getBeansOfType
@NonNull public <T> @NonNull Collection<T> getBeansOfType(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanResolutionContext
Get all beans of the given type and qualifier.- Specified by:
getBeansOfType
in interfaceBeanResolutionContext
- Type Parameters:
T
- The bean type parameter- Parameters:
beanType
- The bean typequalifier
- The qualifier- Returns:
- The found beans
-
streamOfType
@NonNull public <T> @NonNull Stream<T> streamOfType(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanResolutionContext
Obtains a stream of beans of the given type and qualifier.- Specified by:
streamOfType
in interfaceBeanResolutionContext
- Type Parameters:
T
- The bean concrete type- Parameters:
beanType
- The bean typequalifier
- The qualifier- Returns:
- A stream
-
mapOfType
Description copied from interface:BeanResolutionContext
Obtains a map of beans of the given type and qualifier.- Specified by:
mapOfType
in interfaceBeanResolutionContext
- Type Parameters:
V
- The bean type- Parameters:
beanType
- The bean typequalifier
- The qualifier- Returns:
- A map of beans, never
null
.
-
findBean
@NonNull public <T> @NonNull Optional<T> findBean(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanResolutionContext
Find an optional bean of the given type and qualifier.- Specified by:
findBean
in interfaceBeanResolutionContext
- Type Parameters:
T
- The bean type parameter- Parameters:
beanType
- The bean typequalifier
- The qualifier- Returns:
- The found bean wrapped as an
Optional
-
getBeanRegistrations
@NonNull public <T> @NonNull Collection<BeanRegistration<T>> getBeanRegistrations(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanResolutionContext
Obtains the bean registrations for the given type and qualifier.- Specified by:
getBeanRegistrations
in interfaceBeanResolutionContext
- Type Parameters:
T
- The generic type- Parameters:
beanType
- The bean typequalifier
- The qualifier- Returns:
- A collection of
BeanRegistration
-
copyStateFrom
Copy the state from a previous resolution context.- Parameters:
context
- The previous context
-
addDependentBean
Description copied from interface:BeanResolutionContext
Adds a dependent bean to the resolution context.- Specified by:
addDependentBean
in interfaceBeanResolutionContext
- Type Parameters:
T
- The generic type- Parameters:
beanRegistration
- The bean registration
-
destroyInjectScopedBeans
public void destroyInjectScopedBeans()Description copied from interface:BeanResolutionContext
Call back to destroy anyInjectScope
beans.- Specified by:
destroyInjectScopedBeans
in interfaceBeanResolutionContext
- See Also:
-
getAndResetDependentBeans
- Specified by:
getAndResetDependentBeans
in interfaceBeanResolutionContext
- Returns:
- The dependent beans that must be destroyed by an upstream bean
-
markDependentAsFactory
public void markDependentAsFactory()Description copied from interface:BeanResolutionContext
Marks first dependent as factory. Dependent can be missing which means it's a singleton or scoped bean.- Specified by:
markDependentAsFactory
in interfaceBeanResolutionContext
-
getAndResetDependentFactoryBean
- Specified by:
getAndResetDependentFactoryBean
in interfaceBeanResolutionContext
- Returns:
- The dependent factory beans that was used to create the bean in context
-
popDependentBeans
- Specified by:
popDependentBeans
in interfaceBeanResolutionContext
- Returns:
- The current dependent beans that must be destroyed by an upstream bean
-
pushDependentBeans
Description copied from interface:BeanResolutionContext
The push the current dependent beans that must be destroyed by an upstream bean.- Specified by:
pushDependentBeans
in interfaceBeanResolutionContext
- Parameters:
dependentBeans
- Dependent beans collection that can be used to add more dependents
-
getContext
- Specified by:
getContext
in interfaceBeanResolutionContext
- Returns:
- The context
-
getRootDefinition
- Specified by:
getRootDefinition
in interfaceBeanResolutionContext
- Returns:
- The class requested at the root of this resolution context
-
getPath
- Specified by:
getPath
in interfaceBeanResolutionContext
- Returns:
- The path that this resolution has taken so far
-
setAttribute
Description copied from interface:BeanResolutionContext
Store a value within the context.- Specified by:
setAttribute
in interfaceBeanResolutionContext
- Parameters:
key
- The keyvalue
- The value- Returns:
- The previous value or null
-
getAttribute
- Specified by:
getAttribute
in interfaceBeanResolutionContext
- Parameters:
key
- The key- Returns:
- The attribute value
-
removeAttribute
Description copied from interface:BeanResolutionContext
Remove the attribute for the given key.- Specified by:
removeAttribute
in interfaceBeanResolutionContext
- Parameters:
key
- the key- Returns:
- The previous value
-
getAttributes
Description copied from interface:BeanResolutionContext
Get the map representing current attributes.- Specified by:
getAttributes
in interfaceBeanResolutionContext
- Returns:
- All attributes
-
setAttributes
Description copied from interface:BeanResolutionContext
Set new attributes map (The map is supposed to be mutable).- Specified by:
setAttributes
in interfaceBeanResolutionContext
- Parameters:
attributes
- The attributes
-
getCurrentQualifier
- Specified by:
getCurrentQualifier
in interfaceBeanResolutionContext
- Returns:
- The current bean identifier
-
setCurrentQualifier
Description copied from interface:BeanResolutionContext
Sets the current qualifier.- Specified by:
setCurrentQualifier
in interfaceBeanResolutionContext
- Parameters:
qualifier
- The qualifier
-
get
Description copied from interface:ValueResolver
Resolve the given property for the given name.- Specified by:
get
in interfaceValueResolver<CharSequence>
- Type Parameters:
T
- The concrete type- Parameters:
name
- The nameconversionContext
- The conversion context- Returns:
- An optional containing the property value if it exists and is able to be converted
-
get
Description copied from interface:ValueResolver
Resolve the given property for the given name.- Specified by:
get
in interfaceValueResolver<CharSequence>
- Type Parameters:
T
- The concrete type- Parameters:
name
- The namerequiredType
- The required type- Returns:
- An optional containing the property value if it exists and is able to be converted
-
onNewSegment
-