Interface RuntimeBeanDefinition.LookupContext
- All Known Subinterfaces:
RuntimeBeanDefinition.CreationContext, RuntimeBeanDefinition.DisposalContext
- Enclosing interface:
RuntimeBeanDefinition<T>
Every lookup here is resolved through the BeanResolutionContext of the creation or of the
disposal, which is what makes core's own dependency handling apply to it: a dependent object
(a @Prototype or @Dependent bean, for example) that a lookup resolves becomes a dependent
of that creation or disposal and is destroyed with it, a circular dependency is detected, and an
unsatisfied getBean(Argument) fails with the usual
DependencyInjectionException. Resolving the same bean from
getBeanContext() instead resolves it outside that context, where none of that applies.
How long what a lookup resolves lives is decided by the context it was made from:
a dependent resolved from a RuntimeBeanDefinition.CreationContext is destroyed when the created bean is, and one
resolved from a RuntimeBeanDefinition.DisposalContext is destroyed when the disposer returns.
- Since:
- 5.2.0
- Author:
- graemerocher
-
Method Summary
Modifier and TypeMethodDescriptiondefault <V> Optional<V> Looks up a bean of the given type if one exists.<V> Optional<V> Looks up a bean of the given type and qualifier if one exists.default <V> VLooks up a bean of the given type.<V> VLooks up a bean of the given type and qualifier.default <V> Collection<V> getBeansOfType(Argument<V> type) Looks up all the beans of the given type.<V> Collection<V> getBeansOfType(Argument<V> type, @Nullable Qualifier<V> qualifier) Looks up all the beans of the given type and qualifier.
-
Method Details
-
getBeanContext
BeanContext getBeanContext()- Returns:
- The bean context the bean belongs to
-
getBean
Looks up a bean of the given type.- Type Parameters:
V- The looked up type- Parameters:
type- The type to look up- Returns:
- The bean, never
null - Throws:
DependencyInjectionException- If no bean of the type exists
-
getBean
Looks up a bean of the given type and qualifier.- Type Parameters:
V- The looked up type- Parameters:
type- The type to look upqualifier- The qualifier, ornullfor none- Returns:
- The bean, never
null - Throws:
DependencyInjectionException- If no such bean exists
-
findBean
-
findBean
Looks up a bean of the given type and qualifier if one exists.- Type Parameters:
V- The looked up type- Parameters:
type- The type to look upqualifier- The qualifier, ornullfor none- Returns:
- The bean, or empty if none exists
-
getBeansOfType
Looks up all the beans of the given type.- Type Parameters:
V- The looked up type- Parameters:
type- The type to look up- Returns:
- The beans, empty if there are none
-
getBeansOfType
Looks up all the beans of the given type and qualifier.- Type Parameters:
V- The looked up type- Parameters:
type- The type to look upqualifier- The qualifier, ornullfor none- Returns:
- The beans, empty if there are none
-