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
DataSource s 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, wait
builder
public void reset()
MultiTenantDataSource
DataSource
s internal cache.reset
in interface MultiTenantDataSource
public void reset(String tenantId)
MultiTenantDataSource
DataSource
for given tenantId
, if present.reset
in interface MultiTenantDataSource
tenantId
- 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 DataSource
SQLException
public Connection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
SQLException
public PrintWriter getLogWriter() throws SQLException
getLogWriter
in interface CommonDataSource
SQLException
public void setLogWriter(PrintWriter out) throws SQLException
setLogWriter
in interface CommonDataSource
SQLException
public void setLoginTimeout(int seconds) throws SQLException
setLoginTimeout
in interface CommonDataSource
SQLException
public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface CommonDataSource
SQLException
public Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger
in interface CommonDataSource
SQLFeatureNotSupportedException
public <I> I unwrap(Class<I> iface) throws SQLException
unwrap
in interface Wrapper
SQLException
public boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
in interface Wrapper
SQLException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2020 The Holon Platform. All rights reserved.