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
Nested ClassesModifier and TypeClassDescriptionprotected static classAbstract class for a Segment.static final classA segment that represents annotation.static final classA segment that represents a method argument.static classA segment that represents a constructor.static classRepresents a segment that is an event listener.static final classA segment that represents a field.static final classA segment that represents a method argument.static classA segment that represents a method.Nested classes/interfaces inherited from interface io.micronaut.context.BeanResolutionContext
BeanResolutionContext.Path, BeanResolutionContext.Segment<B,T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DefaultBeanContextprotected final BeanResolutionContext.Pathprotected final BeanDefinition<?> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBeanResolutionContext(DefaultBeanContext context, BeanDefinition<?> rootDefinition) -
Method Summary
Modifier and TypeMethodDescription<T> voidaddDependentBean(BeanRegistration<T> beanRegistration) Adds a dependent bean to the resolution context.voidCopy the state from a previous resolution context.voidCall back to destroy anyInjectScopebeans.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 ObjectgetAttribute(CharSequence key) Get the map representing current attributes.<T> TGet 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 BeanContextgetPath()final BeanDefinitionObtains a map of beans of the given type and qualifier.voidMarks first dependent as factory.protected voidonNewSegment(BeanResolutionContext.Segment<?, ?> segment) List<BeanRegistration<?>>voidpushDependentBeans(List<BeanRegistration<?>> dependentBeans) The push the current dependent beans that must be destroyed by an upstream bean.final ObjectRemove the attribute for the given key.resolvePropertyValue(Argument<?> argument, String stringValue, String cliProperty, boolean isPlaceholder) Resolve a property value.final ObjectsetAttribute(CharSequence key, Object value) Store a value within the context.voidsetAttributes(Map<CharSequence, Object> attributes) Set new attributes map (The map is supposed to be mutable).setConfigurationPath(ConfigurationPath configurationPath) Sets the configuration path.voidsetCurrentQualifier(@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.voidvalueResolved(Argument<?> argument, Qualifier<?> qualifier, String property, Object value) Callback when a value is resolved in some other context.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.context.BeanResolutionContext
addInFlightBean, close, copy, getInFlightBean, removeInFlightBeanMethods 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:
getConfigurationPathin interfaceBeanResolutionContext- Returns:
- The configuration path.
-
setConfigurationPath
Description copied from interface:BeanResolutionContextSets the configuration path.- Specified by:
setConfigurationPathin interfaceBeanResolutionContext- Parameters:
configurationPath- The configuration path.- Returns:
- The previous path
-
valueResolved
public void valueResolved(Argument<?> argument, Qualifier<?> qualifier, String property, Object value) Description copied from interface:BeanResolutionContextCallback when a value is resolved in some other context.- Specified by:
valueResolvedin interfaceBeanResolutionContext- Parameters:
argument- The argumentqualifier- The qualifierproperty- The propertyvalue- The value
-
resolvePropertyValue
public Object resolvePropertyValue(Argument<?> argument, String stringValue, String cliProperty, boolean isPlaceholder) Description copied from interface:BeanResolutionContextResolve a property value.- Specified by:
resolvePropertyValuein interfaceBeanResolutionContext- Parameters:
argument- The argumentstringValue- The string valuecliProperty- The CLI propertyisPlaceholder- Whether it is a place holder- Returns:
- The resolved value
-
getBean
@NonNull public <T> T getBean(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanResolutionContextGet a bean of the given type and qualifier.- Specified by:
getBeanin 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:BeanResolutionContextGet all beans of the given type and qualifier.- Specified by:
getBeansOfTypein 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:BeanResolutionContextObtains a stream of beans of the given type and qualifier.- Specified by:
streamOfTypein interfaceBeanResolutionContext- Type Parameters:
T- The bean concrete type- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- A stream
-
mapOfType
Description copied from interface:BeanResolutionContextObtains a map of beans of the given type and qualifier.- Specified by:
mapOfTypein 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:BeanResolutionContextFind an optional bean of the given type and qualifier.- Specified by:
findBeanin 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:BeanResolutionContextObtains the bean registrations for the given type and qualifier.- Specified by:
getBeanRegistrationsin 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:BeanResolutionContextAdds a dependent bean to the resolution context.- Specified by:
addDependentBeanin interfaceBeanResolutionContext- Type Parameters:
T- The generic type- Parameters:
beanRegistration- The bean registration
-
destroyInjectScopedBeans
public void destroyInjectScopedBeans()Description copied from interface:BeanResolutionContextCall back to destroy anyInjectScopebeans.- Specified by:
destroyInjectScopedBeansin interfaceBeanResolutionContext- See Also:
-
getAndResetDependentBeans
- Specified by:
getAndResetDependentBeansin interfaceBeanResolutionContext- Returns:
- The dependent beans that must be destroyed by an upstream bean
-
markDependentAsFactory
public void markDependentAsFactory()Description copied from interface:BeanResolutionContextMarks first dependent as factory. Dependent can be missing which means it's a singleton or scoped bean.- Specified by:
markDependentAsFactoryin interfaceBeanResolutionContext
-
getAndResetDependentFactoryBean
- Specified by:
getAndResetDependentFactoryBeanin interfaceBeanResolutionContext- Returns:
- The dependent factory beans that was used to create the bean in context
-
popDependentBeans
- Specified by:
popDependentBeansin interfaceBeanResolutionContext- Returns:
- The current dependent beans that must be destroyed by an upstream bean
-
pushDependentBeans
Description copied from interface:BeanResolutionContextThe push the current dependent beans that must be destroyed by an upstream bean.- Specified by:
pushDependentBeansin interfaceBeanResolutionContext- Parameters:
dependentBeans- Dependent beans collection that can be used to add more dependents
-
getContext
- Specified by:
getContextin interfaceBeanResolutionContext- Returns:
- The context
-
getRootDefinition
- Specified by:
getRootDefinitionin interfaceBeanResolutionContext- Returns:
- The class requested at the root of this resolution context
-
getPath
- Specified by:
getPathin interfaceBeanResolutionContext- Returns:
- The path that this resolution has taken so far
-
setAttribute
Description copied from interface:BeanResolutionContextStore a value within the context.- Specified by:
setAttributein interfaceBeanResolutionContext- Parameters:
key- The keyvalue- The value- Returns:
- The previous value or null
-
getAttribute
- Specified by:
getAttributein interfaceBeanResolutionContext- Parameters:
key- The key- Returns:
- The attribute value
-
removeAttribute
Description copied from interface:BeanResolutionContextRemove the attribute for the given key.- Specified by:
removeAttributein interfaceBeanResolutionContext- Parameters:
key- the key- Returns:
- The previous value
-
getAttributes
Description copied from interface:BeanResolutionContextGet the map representing current attributes.- Specified by:
getAttributesin interfaceBeanResolutionContext- Returns:
- All attributes
-
setAttributes
Description copied from interface:BeanResolutionContextSet new attributes map (The map is supposed to be mutable).- Specified by:
setAttributesin interfaceBeanResolutionContext- Parameters:
attributes- The attributes
-
getCurrentQualifier
- Specified by:
getCurrentQualifierin interfaceBeanResolutionContext- Returns:
- The current bean identifier
-
setCurrentQualifier
Description copied from interface:BeanResolutionContextSets the current qualifier.- Specified by:
setCurrentQualifierin interfaceBeanResolutionContext- Parameters:
qualifier- The qualifier
-
get
Description copied from interface:ValueResolverResolve the given property for the given name.- Specified by:
getin 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:ValueResolverResolve the given property for the given name.- Specified by:
getin 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
-