FactoryBean that looks up a JNDI object. Exposes the object found in JNDI
when used as bean reference, e.g. for JdbcTemplate'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 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,
because the actual JNDI object type is not known in advance.
Of course, service implementations can lookup e.g. a DataSource from
JNDI themselves, but this class enables central configuration of the
JNDI name, and easy switching to non-JNDI replacements. The latter can
be used for test setups, standalone clients, etc.
Note that switching to e.g. DriverManagerDataSource is just a matter
of configuration: replace the definition of this FactoryBean with a
DriverManagerDataSource definition!
javax.sql.DataSource.The typical usage will be to register this as singleton factory (e.g. for a certain JNDI 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, because the actual JNDI object type is not known in advance.
Of course, service implementations can lookup e.g. a DataSource from JNDI themselves, but this class enables central configuration of the JNDI name, and easy switching to non-JNDI replacements. The latter can be used for test setups, standalone clients, etc.
Note that switching to e.g. DriverManagerDataSource is just a matter of configuration: replace the definition of this FactoryBean with a DriverManagerDataSource definition!