Package org.springframework.data.util
Class BeanLookup
java.lang.Object
org.springframework.data.util.BeanLookup
Simple helper to allow lenient lookup of beans of a given type from a
ListableBeanFactory
. This is not user
facing API but a mere helper for Spring Data configuration code.- Since:
- 2.1
- Author:
- Oliver Gierke
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Lazy<T>
lazyIfAvailable
(Class<T> type, BeanFactory beanFactory) Returns aLazy
for the unique bean of the given type from the givenBeanFactory
(which needs to be aListableBeanFactory
).
-
Method Details
-
lazyIfAvailable
Returns aLazy
for the unique bean of the given type from the givenBeanFactory
(which needs to be aListableBeanFactory
). The lookup will produce aNoUniqueBeanDefinitionException
in case multiple beans of the given type are available in the givenBeanFactory
.- Parameters:
type
- must not be null.beanFactory
- theBeanFactory
to look up the bean from.- Returns:
- a
Lazy
for the unique bean of the given type or the instance provided by the fallback in case no bean of the given type can be found.
-