org.springframework.beans.factory.FactoryBean that looks up a
JNDI object. Exposes the object found in JNDI for bean references,
e.g. for data access object's "dataSource" property in case of a
javax.sql.DataSource .
The typical usage will be to register this as singleton factory
(e.g. for a certain JNDI-bound DataSource) in an application context,
and give bean references to application services that need it.
The default behavior is to look up the JNDI object on startup and cache it.
This can be customized through the "lookupOnStartup" and "cache" properties,
using a
JndiObjectTargetSource underneath. Note that you need to specify
a "proxyInterface" in such a scenario, since the actual JNDI object type is not
known in advance.
Of course, bean classes in a Spring environment may lookup e.g. a DataSource
from JNDI themselves. This class simply enables central configuration of the
JNDI name, and easy switching to non-JNDI alternatives. The latter is
particularly convenient for test setups, reuse in standalone clients, etc.
Note that switching to e.g. DriverManagerDataSource is just a matter of
configuration: Simply replace the definition of this FactoryBean with a
org.springframework.jdbc.datasource.DriverManagerDataSource definition!
author: Juergen Hoeller since: 22.05.2003 See Also: JndiObjectFactoryBean.setProxyInterface See Also: JndiObjectFactoryBean.setLookupOnStartup See Also: JndiObjectFactoryBean.setCache See Also: JndiObjectTargetSource |