public interface ObjectProvider<T> extends ObjectFactory<T>
ObjectFactory
designed specifically for injection points,
allowing for programmatic optionality and lenient not-unique handling.Modifier and Type | Method and 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(java.lang.Object... args)
Return an instance (possibly shared or independent) of the object
managed by this factory.
|
getObject
T getObject(java.lang.Object... args) throws BeansException
Allows for specifying explicit construction arguments, along the
lines of BeanFactory.getBean(String, Object...)
.
args
- arguments to use when creating a corresponding instanceBeansException
- in case of creation errorsObjectFactory.getObject()
T getIfAvailable() throws BeansException
null
if not availableBeansException
- in case of creation errorsObjectFactory.getObject()
T getIfUnique() throws BeansException
null
if not available or
not unique (i.e. multiple candidates found with none marked as primary)BeansException
- in case of creation errorsObjectFactory.getObject()