Interface ObjectProvider<T>
- All Superinterfaces:
ObjectFactory<T>
public interface ObjectProvider<T> extends ObjectFactory<T>
A variant ofObjectFactory
designed specifically for injection points, allowing for programmatic optionality and lenient not-unique handling.- Since:
- 4.3
- Author:
- Juergen Hoeller
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
getIfAvailable()
Return an instance (possibly shared or independent) of the object managed by this factory.T
getIfUnique()
Return an instance (possibly shared or independent) of the object managed by this factory.T
getObject(Object... args)
Return an instance (possibly shared or independent) of the object managed by this factory.Methods inherited from interface org.springframework.beans.factory.ObjectFactory
getObject
Method Detail
getObject
T getObject(Object... args) throws BeansException
Return an instance (possibly shared or independent) of the object managed by this factory.Allows for specifying explicit construction arguments, along the lines of
BeanFactory.getBean(String, Object...)
.- Parameters:
args
- arguments to use when creating a corresponding instance- Returns:
- an instance of the bean
- Throws:
BeansException
- in case of creation errors- See Also:
ObjectFactory.getObject()
getIfAvailable
T getIfAvailable() throws BeansException
Return an instance (possibly shared or independent) of the object managed by this factory.- Returns:
- an instance of the bean, or
null
if not available - Throws:
BeansException
- in case of creation errors- See Also:
ObjectFactory.getObject()
getIfUnique
T getIfUnique() throws BeansException
Return an instance (possibly shared or independent) of the object managed by this factory.- Returns:
- an instance of the bean, or
null
if not available or not unique (i.e. multiple candidates found with none marked as primary) - Throws:
BeansException
- in case of creation errors- See Also:
ObjectFactory.getObject()