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 aLazyfor the unique bean of the given type from the givenBeanFactory(which needs to be aListableBeanFactory).
-
Method Details
-
lazyIfAvailable
Returns aLazyfor the unique bean of the given type from the givenBeanFactory(which needs to be aListableBeanFactory). The lookup will produce aNoUniqueBeanDefinitionExceptionin case multiple beans of the given type are available in the givenBeanFactory.- Parameters:
type- must not be null.beanFactory- theBeanFactoryto look up the bean from.- Returns:
- a
Lazyfor 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.
-