public interface BeanLocator
Core interface for locating and discovering Bean
instances.
Modifier and Type | Method and Description |
---|---|
default <T> java.util.Optional<T> |
findBean(java.lang.Class<T> beanType)
Finds a Bean for the given type.
|
<T> java.util.Optional<T> |
findBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Finds a Bean for the given type and qualifier.
|
default <T> java.util.Optional<T> |
findOrInstantiateBean(java.lang.Class<T> beanType)
Finds a Bean for the given type or attempts to instantiate the given instance.
|
<T> T |
getBean(BeanDefinition<T> definition)
Obtains a Bean for the given bean definition.
|
default <T> T |
getBean(java.lang.Class<T> beanType)
Obtains a Bean for the given type.
|
<T> T |
getBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtains a Bean for the given type and qualifier.
|
<T> java.util.Collection<T> |
getBeansOfType(java.lang.Class<T> beanType)
Get all beans of the given type.
|
<T> java.util.Collection<T> |
getBeansOfType(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Get all beans of the given type.
|
<T> T |
getProxyTargetBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Resolves the proxy target for a given bean type.
|
default <T> java.util.stream.Stream<T> |
streamOfType(java.lang.Class<T> beanType)
Obtain a stream of beans of the given type.
|
<T> java.util.stream.Stream<T> |
streamOfType(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain a stream of beans of the given type.
|
@NonNull <T> T getBean(@NonNull BeanDefinition<T> definition)
T
- The bean type parameterdefinition
- The bean typeNonUniqueBeanException
- When multiple possible bean definitions exist
for the given typeQualifiers
@NonNull <T> T getBean(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifierNonUniqueBeanException
- When multiple possible bean definitions exist
for the given typeQualifiers
@NonNull <T> java.util.Optional<T> findBean(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifierOptional
that is either empty or containing the specified beanNonUniqueBeanException
- When multiple possible bean definitions exist
for the given typeQualifiers
@NonNull <T> java.util.Collection<T> getBeansOfType(@NonNull java.lang.Class<T> beanType)
T
- The bean type parameterbeanType
- The bean type@NonNull <T> java.util.Collection<T> getBeansOfType(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifier@NonNull <T> java.util.stream.Stream<T> streamOfType(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean concrete typebeanType
- The bean typequalifier
- The qualifierQualifiers
@NonNull <T> T getProxyTargetBean(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The generic typebeanType
- The bean typequalifier
- The bean qualifier@NonNull default <T> java.util.stream.Stream<T> streamOfType(@NonNull java.lang.Class<T> beanType)
T
- The bean concrete typebeanType
- The bean type@NonNull default <T> T getBean(@NonNull java.lang.Class<T> beanType)
T
- The bean type parameterbeanType
- The bean typeNonUniqueBeanException
- When multiple possible bean definitions exist
for the given typeNoSuchBeanException
- If the bean doesn't exist@NonNull default <T> java.util.Optional<T> findBean(@NonNull java.lang.Class<T> beanType)
T
- The bean type parameterbeanType
- The bean typeOptional
that is either empty or containing the specified beanNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type@NonNull default <T> java.util.Optional<T> findOrInstantiateBean(@NonNull java.lang.Class<T> beanType)
T
- The bean type parameterbeanType
- The bean typeOptional
that is either empty or containing the specified bean if it could not
be found or instantiatedNonUniqueBeanException
- When multiple possible bean definitions exist
for the given type