Class AbstractBeanResolutionContext
java.lang.Object
io.micronaut.context.AbstractBeanResolutionContext
- All Implemented Interfaces:
BeanLocator, BeanResolutionContext, ConversionServiceProvider, 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 BeanResolutionContext
BeanResolutionContext.Path, BeanResolutionContext.Segment<B,T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DefaultBeanContextprotected final BeanResolutionContext.Pathprotected final @Nullable BeanDefinition<?> Fields inherited from interface BeanResolutionContext
EXISTING_DEPENDENT_BEANS, EXISTING_INTERCEPTOR_REGISTRATIONS, INTERCEPTOR_REGISTRATIONS, SHARED_INTERCEPTOR_REGISTRATIONS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBeanResolutionContext(DefaultBeanContext context, @Nullable BeanDefinition<?> rootDefinition) -
Method Summary
Modifier and TypeMethodDescription<T> voidaddDependentBean(BeanRegistration<T> beanRegistration) Adds a dependent bean to the resolution context.copyForLazyProxyTarget(BeanDefinition<?> proxyBeanDefinition) Copy current context to be used later when resolving a lazy proxy target.final BeanResolutionContextcopyForRuntimeProxyTarget(BeanDefinition<?> targetDefinition) Copies this context for a runtime proxy, whose definition resolves a target through it for as long as the proxy lives.voidCopy the state from a previous resolution context.voidCall back to destroy anyInjectScopebeans.<T> Optional<T> Finds a Bean for the given type and qualifier.<T> Optional<T> Finds a Bean for the given type and qualifier.final <T> Collection<BeanDefinition<T>> findBeanDefinitions(Argument<T> argument, @Nullable BeanDefinition<?> bd) <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.List<BeanRegistration<?>> @Nullable BeanRegistration<?> final @Nullable ObjectgetAttribute(CharSequence key) @Nullable Map<CharSequence, Object> Get the map representing current attributes.<T> TObtains a Bean for the given type and qualifier.<T> TgetBean(BeanDefinition<T> definition) Obtains a Bean for the given bean definition.<T> TObtains a Bean for the given type and qualifier.final <T> BeanRegistration<T> getBeanRegistration(Argument<T> argument, @Nullable Qualifier<T> qualifier) <T> Collection<BeanRegistration<T>> getBeanRegistrations(Argument<T> beanType, @Nullable Qualifier<T> qualifier) Obtains the bean registrations for the given type and qualifier.<T> Collection<T> getBeansOfType(Argument<T> beanType) Get all beans of the given type.<T> Collection<T> getBeansOfType(Argument<T> beanType, @Nullable Qualifier<T> qualifier) Get all beans of the given type.<T> Collection<T> getBeansOfType(Class<T> beanType) Get all beans of the given type.<T> Collection<T> getBeansOfType(Class<T> beanType, @Nullable Qualifier<T> qualifier) Get all beans of the given type.final BeanContextProvides the conversion service.@Nullable Qualifier<?> List<BeanRegistration<?>> getPath()@Nullable PropertyResolver<T> TgetProxyTargetBean(BeanDefinition<T> definition, Argument<T> beanType, @Nullable Qualifier<T> qualifier) Resolves the proxy target for a given proxy bean definition.<T> TgetProxyTargetBean(Class<T> beanType, @Nullable Qualifier<T> qualifier) Resolves the proxy target for a given bean type.final @Nullable BeanDefinitionObtain a map of beans of the given type where the key is the qualifier.voidMarks first dependent as factory.@Nullable List<BeanRegistration<?>> voidpushDependentBeans(@Nullable List<BeanRegistration<?>> dependentBeans) The push the current dependent beans that must be destroyed by an upstream bean.final @Nullable ObjectRemove the attribute for the given key.@Nullable ObjectresolvePropertyValue(Argument<?> argument, String stringValue, @Nullable String cliProperty, boolean isPlaceholder) Resolve a property value.final BeanResolutionContextfinal ObjectsetAttribute(CharSequence key, @Nullable Object value) Store a value within the context.voidsetAttributes(@Nullable Map<CharSequence, Object> attributes) Set new attributes map (The map is supposed to be mutable).@Nullable ConfigurationPathsetConfigurationPath(@Nullable ConfigurationPath configurationPath) Sets the configuration path.voidsetCurrentQualifier(@Nullable Qualifier<?> qualifier) Sets the current qualifier.<T> Stream<T> streamOfType(Argument<T> beanType, @Nullable Qualifier<T> qualifier) Obtain a stream of beans of the given type.<T> Stream<T> streamOfType(Class<T> beanType, @Nullable Qualifier<T> qualifier) Obtain a stream of beans of the given type.voidvalueResolved(Argument<?> argument, @Nullable Qualifier<?> qualifier, String property, @Nullable Object value) Callback when a value is resolved in some other context.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BeanLocator
findBean, findBean, findOrInstantiateBean, getBean, getBean, getProvider, getProvider, getProvider, getProvider, getProxyTargetBean, mapOfType, mapOfType, mapOfType, streamOfType, streamOfTypeMethods inherited from interface BeanResolutionContext
addInFlightBean, close, copy, getInFlightBean, removeInFlightBean, shouldInitializeBeanMethods inherited from interface ValueResolver
get, get
-
Field Details
-
context
-
rootDefinition
-
path
-
-
Constructor Details
-
AbstractBeanResolutionContext
@Internal protected AbstractBeanResolutionContext(DefaultBeanContext context, @Nullable BeanDefinition<?> rootDefinition) - Parameters:
context- The bean contextrootDefinition- The bean root definition
-
-
Method Details
-
getConversionService
Description copied from interface:ConversionServiceProviderProvides the conversion service.- Specified by:
getConversionServicein interfaceConversionServiceProvider- Returns:
- the conversion service
-
getPropertyResolver
- Specified by:
getPropertyResolverin interfaceBeanResolutionContext- Returns:
- The property resolver
-
getConfigurationPath
- Specified by:
getConfigurationPathin interfaceBeanResolutionContext- Returns:
- The configuration path.
-
setConfigurationPath
public @Nullable ConfigurationPath setConfigurationPath(@Nullable ConfigurationPath configurationPath) 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, @Nullable Qualifier<?> qualifier, String property, @Nullable 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 @Nullable Object resolvePropertyValue(Argument<?> argument, String stringValue, @Nullable 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
Description copied from interface:BeanLocatorObtains a Bean for the given type and qualifier.- Specified by:
getBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The potentially parameterized bean typequalifier- The qualifier- Returns:
- An instanceof said bean
- See Also:
-
getBean
Description copied from interface:BeanLocatorObtains a Bean for the given type and qualifier.- Specified by:
getBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- An instanceof said bean
- See Also:
-
getBean
Description copied from interface:BeanLocatorObtains a Bean for the given bean definition.- Specified by:
getBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
definition- The bean type- Returns:
- An instanceof said bean
- See Also:
-
getBeansOfType
Description copied from interface:BeanLocatorGet all beans of the given type.- Specified by:
getBeansOfTypein interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The potenitally parameterized bean typequalifier- The qualifier- Returns:
- The found beans
-
getBeansOfType
Description copied from interface:BeanLocatorGet all beans of the given type.- Specified by:
getBeansOfTypein interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean type- Returns:
- The found beans
-
getBeansOfType
Description copied from interface:BeanLocatorGet all beans of the given type.- Specified by:
getBeansOfTypein interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- The found beans
-
streamOfType
Description copied from interface:BeanLocatorObtain a stream of beans of the given type.- Specified by:
streamOfTypein interfaceBeanLocator- Type Parameters:
T- The bean concrete type- Parameters:
beanType- The potentially parameterized bean typequalifier- The qualifier- Returns:
- A stream of instances
- See Also:
-
streamOfType
Description copied from interface:BeanLocatorObtain a stream of beans of the given type.- Specified by:
streamOfTypein interfaceBeanLocator- Type Parameters:
T- The bean concrete type- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- A stream of instances
- See Also:
-
mapOfType
Description copied from interface:BeanLocatorObtain a map of beans of the given type where the key is the qualifier.- Specified by:
mapOfTypein interfaceBeanLocator- Type Parameters:
V- The bean concrete type- Parameters:
beanType- The potentially parameterized bean typequalifier- The qualifier- Returns:
- A map of instances
- See Also:
-
findBean
Description copied from interface:BeanLocatorFinds a Bean for the given type and qualifier.- Specified by:
findBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- An instance of
Optionalthat is either empty or containing the specified bean - See Also:
-
findBean
Description copied from interface:BeanLocatorFinds a Bean for the given type and qualifier.- Specified by:
findBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- An instance of
Optionalthat is either empty or containing the specified bean - See Also:
-
getBeansOfType
Description copied from interface:BeanLocatorGet all beans of the given type.- Specified by:
getBeansOfTypein interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The potenitally parameterized bean type- Returns:
- The found beans
-
getProxyTargetBean
Description copied from interface:BeanLocatorResolves the proxy target for a given bean type. If the bean has no proxy then the original bean is returned.- Specified by:
getProxyTargetBeanin interfaceBeanLocator- Type Parameters:
T- The generic type- Parameters:
beanType- The bean typequalifier- The bean qualifier- Returns:
- The proxied instance
-
getBeanRegistrations
public <T> Collection<BeanRegistration<T>> getBeanRegistrations(Argument<T> beanType, @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
-
copyForLazyProxyTarget
Description copied from interface:BeanResolutionContextCopy current context to be used later when resolving a lazy proxy target.- Specified by:
copyForLazyProxyTargetin interfaceBeanResolutionContext- Parameters:
proxyBeanDefinition- The proxy bean definition- Returns:
- The bean resolution context
-
copyForRuntimeProxyTarget
@Internal public final BeanResolutionContext copyForRuntimeProxyTarget(BeanDefinition<?> targetDefinition) Copies this context for a runtime proxy, whose definition resolves a target through it for as long as the proxy lives. A proxy can do so from any thread, and on every call, so that onlya copythat is never written to can be shared: each creation of a target happens in its own copy, and a call neither meets another call nor what a failed one left behind.A call of a proxy comes when the resolution that created the proxy is over, so the copy starts from an empty path, whatever the path is now. The proxy creator can also resolve the one target it keeps while it creates the proxy: that one remains a part of the creation, see
runtimeProxyTargetContext().A target that calls its own proxy while it is created is not reported as a circular dependency: the call resolves a further target, and without an end to it the thread runs out of stack.
- Parameters:
targetDefinition- The definition of the target of the proxy- Returns:
- The context for the proxy to retain
- Since:
- 5.2.23
-
runtimeProxyTargetContext
- Returns:
- The context to resolve the target of a runtime proxy through at this moment: the one creating the proxy, on the thread creating it and for as long as it does, so that the target and what it receives are owned by the proxy; this context otherwise
- Since:
- 5.2.23
-
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
-
getDependentBeans
- Specified by:
getDependentBeansin interfaceBeanResolutionContext- Returns:
- The current 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
-
findBeanDefinitions
public final <T> Collection<BeanDefinition<T>> findBeanDefinitions(Argument<T> argument, @Nullable BeanDefinition<?> bd) -
getBeanRegistration
public final <T> BeanRegistration<T> getBeanRegistration(Argument<T> argument, @Nullable Qualifier<T> qualifier) -
getProxyTargetBean
public <T> T getProxyTargetBean(BeanDefinition<T> definition, Argument<T> beanType, @Nullable Qualifier<T> qualifier) Description copied from interface:BeanResolutionContextResolves the proxy target for a given proxy bean definition. If the bean has no proxy then the original bean is returned.- Specified by:
getProxyTargetBeanin interfaceBeanResolutionContext- Type Parameters:
T- The generic type- Parameters:
definition- The proxy bean definitionbeanType- The bean typequalifier- The bean qualifier- Returns:
- The proxied instance
-