Class DataSourceFactory

java.lang.Object
org.conical.common.bbl.db.DataSourceFactory

public class DataSourceFactory extends Object
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 Details

    • DataSourceFactory

      public DataSourceFactory()
  • Method Details

    • getJndiDataSource

      public static DataSource getJndiDataSource(String jndiName)
      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

      public static DataSource getDataSource(DataSourceConfig config)
      Fetches an Oracle DataSource given the passed properties.
      Parameters:
      config - data source configuration
      Returns:
      DataSource generated with those properties