@Internal public interface BeanResolutionContext extends ValueResolver<CharSequence>, AutoCloseable
Modifier and Type | Interface and Description |
---|---|
static interface |
BeanResolutionContext.Path
Represents a path taken to resolve a bean definitions dependencies.
|
static interface |
BeanResolutionContext.Segment<T>
A segment in a path.
|
Modifier and Type | Method and Description |
---|---|
<T> void |
addDependentBean(BeanRegistration<T> beanRegistration)
Adds a dependent bean to the resolution context.
|
<T> void |
addInFlightBean(BeanIdentifier beanIdentifier,
BeanRegistration<T> beanRegistration)
Adds a bean that is created as part of the resolution.
|
default void |
close() |
BeanResolutionContext |
copy()
Copy current context to be used later.
|
void |
destroyInjectScopedBeans()
Call back to destroy any
InjectScope beans. |
<T> Optional<T> |
findBean(Argument<T> beanType,
Qualifier<T> qualifier)
Find an optional bean of the given type and qualifier.
|
default List<BeanRegistration<?>> |
getAndResetDependentBeans() |
default BeanRegistration<?> |
getAndResetDependentFactoryBean() |
Object |
getAttribute(CharSequence key) |
<T> T |
getBean(Argument<T> beanType,
Qualifier<T> qualifier)
Get a bean of the given type and qualifier.
|
<T> Collection<BeanRegistration<T>> |
getBeanRegistrations(Argument<T> beanType,
Qualifier<T> qualifier)
Obtains the bean registrations for the given type and qualifier.
|
<T> Collection<T> |
getBeansOfType(Argument<T> beanType,
Qualifier<T> qualifier)
Get all beans of the given type and qualifier.
|
BeanContext |
getContext() |
Qualifier<?> |
getCurrentQualifier() |
<T> BeanRegistration<T> |
getInFlightBean(BeanIdentifier beanIdentifier)
Obtains an inflight bean for the given identifier.
|
BeanResolutionContext.Path |
getPath() |
BeanDefinition |
getRootDefinition() |
<T> T |
inject(BeanDefinition<?> beanDefinition,
T instance)
Injects a bean.
|
default void |
markDependentAsFactory()
Marks first dependent as factory.
|
default List<BeanRegistration<?>> |
popDependentBeans() |
default void |
pushDependentBeans(List<BeanRegistration<?>> dependentBeans)
The push the current dependent beans that must be destroyed by an upstream bean.
|
Object |
removeAttribute(CharSequence key)
Remove the attribute for the given key.
|
void |
removeInFlightBean(BeanIdentifier beanIdentifier)
Removes a bean that is in the process of being created.
|
Object |
setAttribute(CharSequence key,
Object value)
Store a value within the context.
|
void |
setCurrentQualifier(Qualifier<?> qualifier)
Sets the current qualifier.
|
<T> Stream<T> |
streamOfType(Argument<T> beanType,
Qualifier<T> qualifier)
Obtains a stream of beans of the given type and qualifier.
|
get, get, get, get
default void close()
close
in interface AutoCloseable
@NonNull <T> T getBean(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifier@NonNull <T> Collection<T> getBeansOfType(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifier@NonNull <T> Stream<T> streamOfType(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean concrete typebeanType
- The bean typequalifier
- The qualifier@NonNull <T> Optional<T> findBean(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifierOptional
@NonNull <T> T inject(@Nullable BeanDefinition<?> beanDefinition, @NonNull T instance)
T
- The instance typebeanDefinition
- The requesting bean definitioninstance
- The instance@NonNull <T> Collection<BeanRegistration<T>> getBeanRegistrations(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The generic typebeanType
- The bean typequalifier
- The qualifierBeanRegistration
void destroyInjectScopedBeans()
InjectScope
beans.InjectScope
BeanResolutionContext copy()
BeanContext getContext()
BeanDefinition getRootDefinition()
BeanResolutionContext.Path getPath()
Object setAttribute(CharSequence key, Object value)
key
- The keyvalue
- The valueObject getAttribute(CharSequence key)
key
- The keyObject removeAttribute(CharSequence key)
key
- the key<T> void addInFlightBean(BeanIdentifier beanIdentifier, BeanRegistration<T> beanRegistration)
BeanContext.inject(Object)
T
- The instance typebeanIdentifier
- The bean identifierbeanRegistration
- The bean registrationvoid removeInFlightBean(BeanIdentifier beanIdentifier)
BeanContext.inject(Object)
beanIdentifier
- The bean identifier@Nullable <T> BeanRegistration<T> getInFlightBean(BeanIdentifier beanIdentifier)
PostConstruct
method that also triggers bean resolution of the same bean.T
- The bean typebeanIdentifier
- The bean identifier@Nullable Qualifier<?> getCurrentQualifier()
void setCurrentQualifier(@Nullable Qualifier<?> qualifier)
qualifier
- The qualifier<T> void addDependentBean(BeanRegistration<T> beanRegistration)
T
- The generic typebeanRegistration
- The bean registration@NonNull default List<BeanRegistration<?>> getAndResetDependentBeans()
@Nullable default List<BeanRegistration<?>> popDependentBeans()
default void pushDependentBeans(@Nullable List<BeanRegistration<?>> dependentBeans)
dependentBeans
- Dependent beans collection that can be used to add more dependentsdefault void markDependentAsFactory()
@Nullable default BeanRegistration<?> getAndResetDependentFactoryBean()