Package io.micronaut.context
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 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.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(@NonNull Argument<T> argument, 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.final ObjectgetAttribute(CharSequence key) 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, Qualifier<T> 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.<T> Collection<T>getBeansOfType(Argument<T> beanType) 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, Qualifier<T> qualifier) Get all beans of the given type.final BeanContextProvides the conversion service.getPath()<T> TgetProxyTargetBean(BeanDefinition<T> definition, Argument<T> beanType, Qualifier<T> qualifier) Resolves the proxy target for a given proxy bean definition.<T> TgetProxyTargetBean(Class<T> beanType, Qualifier<T> qualifier) Resolves the proxy target for a given bean type.final BeanDefinitionObtain a map of beans of the given type where the key is the qualifier.voidMarks first dependent as factory.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) Obtain a stream of beans of the given type.<T> Stream<T>streamOfType(Class<T> beanType, Qualifier<T> qualifier) Obtain a stream of beans of the given type.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.BeanLocator
findBean, findBean, findOrInstantiateBean, getBean, getBean, getProvider, getProvider, getProvider, getProvider, getProxyTargetBean, mapOfType, mapOfType, mapOfType, streamOfType, streamOfTypeMethods 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
-
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
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: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
@NonNull public <T> @NonNull Collection<T> getBeansOfType(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) 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
@NonNull public <T> @NonNull Stream<T> streamOfType(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) 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
@NonNull public <T> @NonNull Optional<T> findBean(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) 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
@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
-
findBeanDefinitions
public final <T> Collection<BeanDefinition<T>> findBeanDefinitions(@NonNull @NonNull Argument<T> argument, BeanDefinition<?> bd) -
getBeanRegistration
public final <T> BeanRegistration<T> getBeanRegistration(Argument<T> argument, Qualifier<T> qualifier) -
getProxyTargetBean
public <T> T getProxyTargetBean(BeanDefinition<T> definition, Argument<T> beanType, 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
-