try {
DataSourceConfigurationValue config = getConfiguration( importedServiceDescriptor.identity() );
if ( !config.enabled().get() ) {
// Not started
throw new ServiceImporterException( "DataSource not enabled" );
}
// Instantiate pool
pool = setupDataSourcePool( config );
pools.put( importedServiceDescriptor.identity(), pool );
LOGGER.info( "Starting up DataSource '" + importedServiceDescriptor.identity() + "' for: {}@{}", config.username().get(), config.url().get() );
} catch ( Exception e ) {
throw new ServiceImporterException( e );
}
// Test the pool
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader( null );
try {
pool.getConnection().close();
LOGGER.info( "Database for DataSource is up!" );
} catch ( SQLException e ) {
LOGGER.warn( "Database for DataSource " + importedServiceDescriptor.identity() + " is not currently available" );
throw new ServiceImporterException( "Database for DataSource " + importedServiceDescriptor.identity() + " is not currently available", e );
} finally {
Thread.currentThread().setContextClassLoader( cl );
}
}