public interface BeanDefinitionRegistry
Core bean definition registry interface containing methods to find BeanDefinition
instances.
Modifier and Type | Method and Description |
---|---|
default boolean |
containsBean(java.lang.Class beanType)
Return whether the bean of the given type is contained within this context.
|
<T> boolean |
containsBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Return whether the bean of the given type is contained within this context.
|
java.util.Optional<BeanConfiguration> |
findBeanConfiguration(java.lang.String configurationName)
Obtain a bean configuration by name.
|
default <T> java.util.Optional<BeanDefinition<T>> |
findBeanDefinition(java.lang.Class<T> beanType)
Obtain a
BeanDefinition for the given type. |
<T> java.util.Optional<BeanDefinition<T>> |
findBeanDefinition(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
<T> java.util.Optional<BeanRegistration<T>> |
findBeanRegistration(T bean)
Obtain a
BeanDefinition for the given bean. |
<T> java.util.Optional<BeanDefinition<T>> |
findProxyBeanDefinition(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition . |
<T> java.util.Optional<BeanDefinition<T>> |
findProxyTargetBeanDefinition(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition . |
<T> java.util.Collection<BeanRegistration<T>> |
getActiveBeanRegistrations(java.lang.Class<T> beanType)
Find active
Singleton beans for the given bean type. |
java.util.Collection<BeanRegistration<?>> |
getActiveBeanRegistrations(Qualifier<?> qualifier)
Find active
Singleton beans for the given qualifier. |
java.util.Collection<BeanDefinition<?>> |
getAllBeanDefinitions()
Get all of the registered
BeanDefinition . |
default <T> BeanDefinition<T> |
getBeanDefinition(java.lang.Class<T> beanType)
Obtain a
BeanDefinition for the given type. |
default <T> BeanDefinition<T> |
getBeanDefinition(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
java.util.Collection<BeanDefinitionReference<?>> |
getBeanDefinitionReferences()
Get all of the enabled
BeanDefinitionReference . |
<T> java.util.Collection<BeanDefinition<T>> |
getBeanDefinitions(java.lang.Class<T> beanType)
Obtain a
BeanDefinition for the given type. |
<T> java.util.Collection<BeanDefinition<T>> |
getBeanDefinitions(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
java.util.Collection<BeanDefinition<?>> |
getBeanDefinitions(Qualifier<java.lang.Object> qualifier)
Get all of the
BeanDefinition for the given qualifier. |
<T> java.util.Collection<BeanRegistration<T>> |
getBeanRegistrations(java.lang.Class<T> beanType)
Find and if necessary initialize
Singleton beans for the given bean type, returning all the active registrations. |
default <T> BeanDefinition<T> |
getProxyTargetBeanDefinition(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition . |
default <T> BeanDefinitionRegistry |
registerSingleton(java.lang.Class<T> type,
T singleton)
Registers a new singleton bean at runtime.
|
default <T> BeanDefinitionRegistry |
registerSingleton(java.lang.Class<T> type,
T singleton,
Qualifier<T> qualifier)
Registers a new singleton bean at runtime.
|
<T> BeanDefinitionRegistry |
registerSingleton(java.lang.Class<T> type,
T singleton,
Qualifier<T> qualifier,
boolean inject)
Registers a new singleton bean at runtime.
|
default BeanDefinitionRegistry |
registerSingleton(java.lang.Object singleton)
Registers a new singleton bean at runtime.
|
default BeanDefinitionRegistry |
registerSingleton(java.lang.Object singleton,
boolean inject)
Registers a new singleton bean at runtime.
|
<T> boolean containsBean(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The concrete typebeanType
- The bean typequalifier
- The qualifier for the bean@NonNull <T> BeanDefinitionRegistry registerSingleton(@NonNull java.lang.Class<T> type, @NonNull T singleton, @Nullable Qualifier<T> qualifier, boolean inject)
Registers a new singleton bean at runtime. This method expects that the bean definition data will have been compiled ahead of time.
If bean definition data is found the method will perform dependency injection on the instance followed by
invoking any PostConstruct
hooks.
If no bean definition data is found the bean is registered as is.
T
- The concrete typetype
- The bean typesingleton
- The singleton beanqualifier
- The bean qualifierinject
- Whether the singleton should be injected (defaults to true)@NonNull java.util.Optional<BeanConfiguration> findBeanConfiguration(@NonNull java.lang.String configurationName)
configurationName
- The configuration name@NonNull <T> java.util.Optional<BeanDefinition<T>> findBeanDefinition(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinition
for the given type.T
- The concrete typebeanType
- The typequalifier
- The qualifierOptional
of the bean definitionNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type@NonNull <T> java.util.Optional<BeanRegistration<T>> findBeanRegistration(@NonNull T bean)
BeanDefinition
for the given bean.T
- The concrete typebean
- The beanOptional
of the bean definitionNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type@NonNull <T> java.util.Collection<BeanDefinition<T>> getBeanDefinitions(@NonNull java.lang.Class<T> beanType)
BeanDefinition
for the given type.T
- The concrete typebeanType
- The typeOptional
of the bean definitionNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type@NonNull <T> java.util.Collection<BeanDefinition<T>> getBeanDefinitions(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinition
for the given type.T
- The concrete typebeanType
- The typequalifier
- The qualifierOptional
of the bean definitionNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type@NonNull java.util.Collection<BeanDefinition<?>> getBeanDefinitions(@NonNull Qualifier<java.lang.Object> qualifier)
BeanDefinition
for the given qualifier.qualifier
- The qualifer@NonNull java.util.Collection<BeanDefinition<?>> getAllBeanDefinitions()
BeanDefinition
.@NonNull java.util.Collection<BeanDefinitionReference<?>> getBeanDefinitionReferences()
BeanDefinitionReference
.@NonNull java.util.Collection<BeanRegistration<?>> getActiveBeanRegistrations(@NonNull Qualifier<?> qualifier)
Singleton
beans for the given qualifier. Note that
this method can return multiple registrations for a given singleton bean instance since each bean may have multiple qualifiers.qualifier
- The qualifier@NonNull <T> java.util.Collection<BeanRegistration<T>> getActiveBeanRegistrations(@NonNull java.lang.Class<T> beanType)
Singleton
beans for the given bean type. Note that
this method can return multiple registrations for a given singleton bean instance since each bean may have multiple qualifiers.T
- The concrete typebeanType
- The bean type@NonNull <T> java.util.Collection<BeanRegistration<T>> getBeanRegistrations(@NonNull java.lang.Class<T> beanType)
Singleton
beans for the given bean type, returning all the active registrations. Note that
this method can return multiple registrations for a given singleton bean instance since each bean may have multiple qualifiers.T
- The concrete typebeanType
- The bean type@NonNull <T> java.util.Optional<BeanDefinition<T>> findProxyTargetBeanDefinition(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinition
for a ProxyBeanDefinition
.T
- The concrete typebeanType
- The typequalifier
- The qualifierOptional
of the bean definitionNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type@NonNull <T> java.util.Optional<BeanDefinition<T>> findProxyBeanDefinition(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinition
for a ProxyBeanDefinition
.T
- The concrete typebeanType
- The typequalifier
- The qualifierOptional
of the bean definitionNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type@NonNull default <T> BeanDefinitionRegistry registerSingleton(@NonNull java.lang.Class<T> type, @NonNull T singleton, @Nullable Qualifier<T> qualifier)
Registers a new singleton bean at runtime. This method expects that the bean definition data will have been compiled ahead of time.
If bean definition data is found the method will perform dependency injection on the instance followed by
invoking any PostConstruct
hooks.
If no bean definition data is found the bean is registered as is.
T
- The concrete typetype
- The bean typesingleton
- The singleton beanqualifier
- The bean qualifierdefault <T> BeanDefinitionRegistry registerSingleton(@NonNull java.lang.Class<T> type, @NonNull T singleton)
Registers a new singleton bean at runtime. This method expects that the bean definition data will have been compiled ahead of time.
If bean definition data is found the method will perform dependency injection on the instance followed by
invoking any PostConstruct
hooks.
If no bean definition data is found the bean is registered as is.
T
- The concrete typetype
- the bean typesingleton
- The singleton bean@NonNull default <T> BeanDefinition<T> getBeanDefinition(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinition
for the given type.T
- The concrete typebeanType
- The typequalifier
- The qualifierBeanDefinition
NonUniqueBeanException
- When multiple possible bean definitions exist
for the given typeNoSuchBeanException
- If the bean cannot be found@NonNull default <T> BeanDefinition<T> getProxyTargetBeanDefinition(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinition
for a ProxyBeanDefinition
.T
- The concrete typebeanType
- The typequalifier
- The qualifierBeanDefinition
NonUniqueBeanException
- When multiple possible bean definitions exist
for the given typeNoSuchBeanException
- If the bean cannot be found@NonNull default <T> BeanDefinition<T> getBeanDefinition(@NonNull java.lang.Class<T> beanType)
BeanDefinition
for the given type.T
- The concrete typebeanType
- The typeBeanDefinition
NonUniqueBeanException
- When multiple possible bean definitions exist
for the given typeNoSuchBeanException
- If the bean cannot be found@NonNull default <T> java.util.Optional<BeanDefinition<T>> findBeanDefinition(@NonNull java.lang.Class<T> beanType)
BeanDefinition
for the given type.T
- The concrete typebeanType
- The typeOptional
of the bean definitionNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type@NonNull default BeanDefinitionRegistry registerSingleton(@NonNull java.lang.Object singleton)
Registers a new singleton bean at runtime. This method expects that the bean definition data will have been compiled ahead of time.
If bean definition data is found the method will perform dependency injection on the instance followed by
invoking any PostConstruct
hooks.
If no bean definition data is found the bean is registered as is.
singleton
- The singleton bean@NonNull default BeanDefinitionRegistry registerSingleton(@NonNull java.lang.Object singleton, boolean inject)
Registers a new singleton bean at runtime. This method expects that the bean definition data will have been compiled ahead of time.
If bean definition data is found the method will perform dependency injection on the instance followed by
invoking any PostConstruct
hooks.
If no bean definition data is found the bean is registered as is.
singleton
- The singleton beaninject
- Whether the singleton should be injected (defaults to true)default boolean containsBean(@NonNull java.lang.Class beanType)
beanType
- The bean type