Search in sources :

Example 1 with DecoratingDataSource

use of org.apache.openjpa.lib.jdbc.DecoratingDataSource in project oozie by apache.

the class JPAService method getBasicDataSource.

private BasicDataSource getBasicDataSource() {
    // Get the BasicDataSource object; it could be wrapped in a DecoratingDataSource
    // It might also not be a BasicDataSource if the user configured something different
    BasicDataSource basicDataSource = null;
    final OpenJPAEntityManagerFactorySPI spi = (OpenJPAEntityManagerFactorySPI) factory;
    final Object connectionFactory = spi.getConfiguration().getConnectionFactory();
    if (connectionFactory instanceof DecoratingDataSource) {
        final DecoratingDataSource decoratingDataSource = (DecoratingDataSource) connectionFactory;
        basicDataSource = (BasicDataSource) decoratingDataSource.getInnermostDelegate();
    } else if (connectionFactory instanceof BasicDataSource) {
        basicDataSource = (BasicDataSource) connectionFactory;
    }
    return basicDataSource;
}
Also used : DecoratingDataSource(org.apache.openjpa.lib.jdbc.DecoratingDataSource) OpenJPAEntityManagerFactorySPI(org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Aggregations

BasicDataSource (org.apache.commons.dbcp.BasicDataSource)1 DecoratingDataSource (org.apache.openjpa.lib.jdbc.DecoratingDataSource)1 OpenJPAEntityManagerFactorySPI (org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI)1