Class TenantRoutingDataSource
java.lang.Object
org.springframework.jdbc.datasource.AbstractDataSource
org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
org.chenile.multids.TenantRoutingDataSource
- All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource, InitializingBean
Routes each new connection to the tenant's database: the tenant pinned on the thread by
TenantScope first, then the ContextContainer tenant. The pin keeps background work on
one tenant's database even when code it calls changes or clears the ContextContainer.-
Field Summary
FieldsFields inherited from class AbstractDataSource
logger -
Constructor Summary
ConstructorsConstructorDescriptionTenantRoutingDataSource(TenantScope tenantScope, ContextContainer contextContainer) -
Method Summary
Methods inherited from class AbstractRoutingDataSource
afterPropertiesSet, createConnectionBuilder, createShardingKeyBuilder, determineTargetDataSource, getConnection, getConnection, getResolvedDataSources, getResolvedDefaultDataSource, initialize, isWrapperFor, resolveSpecifiedDataSource, resolveSpecifiedLookupKey, setDataSourceLookup, setDefaultTargetDataSource, setLenientFallback, setTargetDataSources, unwrapMethods inherited from class AbstractDataSource
getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriter
-
Field Details
-
tenantScope
-
contextContainer
-
-
Constructor Details
-
TenantRoutingDataSource
-
-
Method Details
-
determineCurrentLookupKey
- Specified by:
determineCurrentLookupKeyin classAbstractRoutingDataSource
-
CHENILE