Package org.conical.common.bbl.db
Class DataSourceFactory
java.lang.Object
org.conical.common.bbl.db.DataSourceFactory
Factory class that ensures only one DataSource is created for each set of
database connection information. A cache of DataSources is maintained and
when a DataSource is requested, the cache is consulted before creating a
new DataSource. This class is threadsafe and uses DbConnectionBroker as the
underlying connection pooling mechanism.
- Author:
- rdoherty
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DataSource
getDataSource
(DataSourceConfig config) Fetches an Oracle DataSource given the passed properties.static DataSource
getJndiDataSource
(String jndiName) Looks up a DataSource in JNDI registered under the passed name and returns it.
-
Constructor Details
-
DataSourceFactory
public DataSourceFactory()
-
-
Method Details
-
getJndiDataSource
Looks up a DataSource in JNDI registered under the passed name and returns it. Note: This assumes the Tomcat implementation of JNDI.- Parameters:
jndiName
- name with which data source should be looked up- Returns:
- data source registered through JNDI
- Throws:
BBLRuntimeException
- if no DataSource is configured with that name
-
getDataSource
Fetches an Oracle DataSource given the passed properties.- Parameters:
config
- data source configuration- Returns:
- DataSource generated with those properties
-