public class DefaultMultiTenantDataSource extends Object implements MultiTenantDataSource
MultiTenantDataSource implementation.
An internal cache is used to store and reuse tenant DataSource instances.
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultMultiTenantDataSource.DefaultBuilder
Default
MultiTenantDataSource builder. |
MultiTenantDataSource.Builder| Constructor and Description |
|---|
DefaultMultiTenantDataSource()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Connection |
getConnection() |
Connection |
getConnection(String username,
String password) |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
boolean |
isWrapperFor(Class<?> iface) |
void |
reset()
Reset tenant
DataSources internal cache. |
void |
reset(String tenantId)
Reset internal cached
DataSource for given tenantId, if present. |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter out) |
void |
setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider)
Set the
TenantDataSourceProvider to use to obtain configured DataSource instances according to current
tenant id. |
void |
setTenantResolver(com.holonplatform.core.tenancy.TenantResolver tenantResolver)
Set the
TenantResolver to use to obtain the current tenant id. |
<I> I |
unwrap(Class<I> iface) |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuilderpublic void reset()
MultiTenantDataSourceDataSources internal cache.reset in interface MultiTenantDataSourcepublic void reset(String tenantId)
MultiTenantDataSourceDataSource for given tenantId, if present.reset in interface MultiTenantDataSourcetenantId - Tenant id to resetpublic void setTenantResolver(com.holonplatform.core.tenancy.TenantResolver tenantResolver)
TenantResolver to use to obtain the current tenant id.
If not setted, the default context resource TenantResolver.getCurrent() is used if available.
tenantResolver - the TenantResolver to setpublic void setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider)
TenantDataSourceProvider to use to obtain configured DataSource instances according to current
tenant id.
If not setted, the default context resource TenantDataSourceProvider.getCurrent() is used if available.
tenantDataSourceProvider - the TenantDataSourceProvider to setpublic Connection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic Connection getConnection(String username, String password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSourceSQLExceptionpublic void setLogWriter(PrintWriter out) throws SQLException
setLogWriter in interface CommonDataSourceSQLExceptionpublic void setLoginTimeout(int seconds)
throws SQLException
setLoginTimeout in interface CommonDataSourceSQLExceptionpublic int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLExceptionpublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionpublic <I> I unwrap(Class<I> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2019 The Holon Platform. All rights reserved.