
io.ebeaninternal.server.core.MultiTenantDbSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebeaninternal.server.core;
import io.ebean.config.CurrentTenantProvider;
import io.ebean.config.TenantDataSourceProvider;
import io.ebeaninternal.server.transaction.DataSourceSupplier;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
/**
* DataSource supplier based on DataSource per Tenant.
*/
class MultiTenantDbSupplier implements DataSourceSupplier {
private final CurrentTenantProvider tenantProvider;
private final TenantDataSourceProvider dataSourceProvider;
MultiTenantDbSupplier(CurrentTenantProvider tenantProvider, TenantDataSourceProvider dataSourceProvider) {
this.tenantProvider = tenantProvider;
this.dataSourceProvider = dataSourceProvider;
}
@Override
public DataSource getReadOnlyDataSource() {
// read only datasource not supported with DB per tenant at this stage
return null;
}
@Override
public DataSource getDataSource() {
return dataSourceProvider.dataSource(tenantProvider.currentId());
}
@Override
public Connection getConnection(Object tenantId) throws SQLException {
return dataSourceProvider.dataSource(tenantId).getConnection();
}
@Override
public Connection getReadOnlyConnection(Object tenantId) throws SQLException {
throw new SQLException("Not currently supported");
}
@Override
public void shutdown(boolean deregisterDriver) {
dataSourceProvider.shutdown(deregisterDriver);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy