public interface BeanLocator
Core interface for locating and discovering Bean instances.
| Modifier and Type | Method and Description |
|---|---|
default <T> Optional<T> |
findBean(Class<T> beanType)
Finds a Bean for the given type.
|
<T> Optional<T> |
findBean(Class<T> beanType,
Qualifier<T> qualifier)
Finds a Bean for the given type and qualifier.
|
default <T> Optional<T> |
findOrInstantiateBean(Class<T> beanType)
Finds a Bean for the given type or attempts to instantiate the given instance.
|
default <T> T |
getBean(Class<T> beanType)
Obtains a Bean for the given type.
|
<T> T |
getBean(Class<T> beanType,
Qualifier<T> qualifier)
Obtains a Bean for the given type and qualifier.
|
<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.
|
<T> T |
getProxyTargetBean(Class<T> beanType,
Qualifier<T> qualifier)
Resolves the proxy target for a given bean type.
|
default <T> Stream<T> |
streamOfType(Class<T> beanType)
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.
|
@Nonnull <T> T getBean(@Nonnull 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> Optional<T> findBean(@Nonnull 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> Collection<T> getBeansOfType(@Nonnull Class<T> beanType)
T - The bean type parameterbeanType - The bean type@Nonnull <T> Collection<T> getBeansOfType(@Nonnull Class<T> beanType, @Nullable Qualifier<T> qualifier)
T - The bean type parameterbeanType - The bean typequalifier - The qualifier@Nonnull <T> Stream<T> streamOfType(@Nonnull Class<T> beanType, @Nullable Qualifier<T> qualifier)
T - The bean concrete typebeanType - The bean typequalifier - The qualifierQualifiers@Nonnull <T> T getProxyTargetBean(@Nonnull Class<T> beanType, @Nullable Qualifier<T> qualifier)
T - The generic typebeanType - The bean typequalifier - The bean qualifier@Nonnull default <T> Stream<T> streamOfType(@Nonnull Class<T> beanType)
T - The bean concrete typebeanType - The bean type@Nonnull default <T> T getBean(@Nonnull 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> Optional<T> findBean(@Nonnull 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> Optional<T> findOrInstantiateBean(@Nonnull 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