Class TenantAwareDataSource
java.lang.Object
org.flowable.common.engine.impl.cfg.multitenant.TenantAwareDataSource
- All Implemented Interfaces:
Wrapper
,CommonDataSource
,DataSource
A
DataSource
implementation that switches the currently used datasource based on the current values of the TenantInfoHolder
.
When a Connection
is requested from this DataSource
, the correct DataSource
for the current tenant will be determined and used.
Heavily influenced and inspired by Spring's AbstractRoutingDataSource.- Author:
- Joram Barrez
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataSource
(Object key, DataSource dataSource) getConnection
(String username, String password) protected DataSource
int
boolean
isWrapperFor
(Class<?> iface) void
removeDataSource
(Object key) void
setDataSources
(Map<Object, DataSource> dataSources) void
setLoginTimeout
(int seconds) void
setLogWriter
(PrintWriter out) <T> T
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Field Details
-
tenantInfoHolder
-
dataSources
-
-
Constructor Details
-
TenantAwareDataSource
-
-
Method Details
-
addDataSource
-
removeDataSource
-
getConnection
- Specified by:
getConnection
in interfaceDataSource
- Throws:
SQLException
-
getConnection
- Specified by:
getConnection
in interfaceDataSource
- Throws:
SQLException
-
getCurrentDataSource
-
getLoginTimeout
- Specified by:
getLoginTimeout
in interfaceCommonDataSource
- Specified by:
getLoginTimeout
in interfaceDataSource
- Throws:
SQLException
-
getParentLogger
- Specified by:
getParentLogger
in interfaceCommonDataSource
- Throws:
SQLFeatureNotSupportedException
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
getDataSources
-
setDataSources
-
getLogWriter
- Specified by:
getLogWriter
in interfaceCommonDataSource
- Specified by:
getLogWriter
in interfaceDataSource
- Throws:
SQLException
-
setLogWriter
- Specified by:
setLogWriter
in interfaceCommonDataSource
- Specified by:
setLogWriter
in interfaceDataSource
- Throws:
SQLException
-
setLoginTimeout
- Specified by:
setLoginTimeout
in interfaceCommonDataSource
- Specified by:
setLoginTimeout
in interfaceDataSource
- Throws:
SQLException
-