com.sap.cloud.mt.runtime.HikariDataSourceLookup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multi-tenant-runtime Show documentation
Show all versions of multi-tenant-runtime Show documentation
Spring Boot Enablement Parent
/******************************************************************************
* © 2020 SAP SE or an SAP affiliate company. All rights reserved. *
******************************************************************************/
package com.sap.cloud.mt.runtime;
import com.sap.cloud.mt.subscription.DataSourceInfo;
import com.sap.cloud.mt.subscription.InstanceLifecycleManager;
import com.sap.cloud.mt.subscription.exceptions.InternalError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.sql.DataSource;
import java.io.Closeable;
import java.io.IOException;
public class HikariDataSourceLookup extends DataSourceLookup {
private static Logger logger = LoggerFactory.getLogger(HikariDataSourceLookup.class);
private final EnvironmentAccess environment;
private final DataPoolSettings poolSettings;
public HikariDataSourceLookup(InstanceLifecycleManager instanceLifecycleManager, EnvironmentAccess environment,
DataPoolSettings poolSettings, boolean oneDataSourcePerDb) {
super(instanceLifecycleManager, oneDataSourcePerDb);
this.environment = environment;
this.poolSettings = poolSettings;
}
@Override
public DataSource create(DataSourceInfo info) throws InternalError {
DataSourceCreator dataSourceCreator = null;
logger.debug("Hikari data source pool taken");
dataSourceCreator = new DataSourceCreatorHikari(poolSettings);
return dataSourceCreator.create(info, environment);
}
@Override
public void closeDataSource(DataSource dataSource) {
if (dataSource == null) {
return;
}
logger.debug("Close Hikari data source pool");
Closeable closeable = (Closeable) dataSource;
try {
closeable.close();
} catch (IOException e) {
logger.error("Could not close Hikari data source pool ", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy