public class MockTenant extends Object implements Tenant
| Constructor and Description |
|---|
MockTenant(String tenantId) |
| Modifier and Type | Method and Description |
|---|---|
void |
activateAlternativeMasterDataSource(String id)
Switches to a specified (by the id) master data source for the current thread.
|
String |
activateSlaveDataSource()
Switches to a slave data source for the current thread.
|
void |
activateSlaveDataSource(String id)
Switches to a specified (by the id) slave data source for the current thread.
|
Thread |
createAndRegisterBackgroundThread(Runnable payload,
ThreadFactory factory) |
void |
deactivateAlternativeDataSource()
After a alternative slave or master data source has been activated for the current thread it's necessary to
de-activate it again! After this the base master data source is active (again).
|
void |
deactivateSlaveDataSource()
After slave data source has been activated for the current thread it's necessary to de-activate it again! After
this the master data source is active (again).
|
boolean |
equals(Object object) |
void |
forceMasterDataSource()
Enforces the usage of a master data source for all subsequent calls to
DataSourceProvider.getDataSource() no matter if a
slave data source has been activated or not. |
JaloSession |
getActiveSession() |
Set<String> |
getAllAlternativeMasterDataSourceIDs()
Provides IDs of all available alternative master data sources.
|
Collection<HybrisDataSource> |
getAllAlternativeMasterDataSources()
Returns all known alternative master data sources as Collection.
|
Set<String> |
getAllDataSourceIDs() |
Set<String> |
getAllSlaveDataSourceIDs()
Provides IDs of all available slave data sources.
|
Collection<HybrisDataSource> |
getAllSlaveDataSources()
Returns all known slave data sources as Collection.
|
Cache |
getCache() |
ConfigIntf |
getConfig() |
HybrisDataSource |
getDataSource()
Returns currently active data source.
|
HybrisDataSource |
getDataSource(String className)
Returns new data source.
|
InvalidationManager |
getInvalidationManager() |
JaloConnection |
getJaloConnection() |
HybrisDataSource |
getMasterDataSource()
Returns master data source no matter which one is currently active.
|
PersistenceManager |
getPersistenceManager() |
PersistencePool |
getPersistencePool() |
SerialNumberGenerator |
getSerialNumberGenerator() |
SingletonCreator |
getSingletonCreator() |
SystemEJB |
getSystemEJB() |
String |
getTenantID() |
List<String> |
getTenantSpecificExtensionNames() |
Locale |
getTenantSpecificLocale() |
TimeZone |
getTenantSpecificTimeZone() |
ThreadPool |
getThreadPool() |
ThreadPool |
getWorkersThreadPool() |
int |
hashCode() |
boolean |
isAlternativeMasterDataSource()
Tells whether the current active data source is a alternative master data source.
|
boolean |
isForceMaster()
If on the current data source (slave/master) the method
DataSourceProvider.forceMasterDataSource() was called then this
method returns true. |
boolean |
isSlaveDataSource()
Tells whether current data source is a slave data source.
|
void |
resetTenantRestartMarker() |
public MockTenant(String tenantId)
public void resetTenantRestartMarker()
resetTenantRestartMarker in interface Tenantpublic HybrisDataSource getDataSource(String className)
DataSourceProvidergetDataSource in interface DataSourceProviderpublic ConfigIntf getConfig()
public HybrisDataSource getDataSource()
DataSourceProvidergetDataSource in interface DataSourceProviderpublic InvalidationManager getInvalidationManager()
getInvalidationManager in interface Tenantpublic JaloConnection getJaloConnection()
getJaloConnection in interface Tenantpublic PersistenceManager getPersistenceManager()
getPersistenceManager in interface Tenantpublic PersistencePool getPersistencePool()
getPersistencePool in interface Tenantpublic SerialNumberGenerator getSerialNumberGenerator()
getSerialNumberGenerator in interface Tenantpublic SingletonCreator getSingletonCreator()
getSingletonCreator in interface Tenantpublic SystemEJB getSystemEJB()
getSystemEJB in interface Tenantpublic String getTenantID()
getTenantID in interface Tenantpublic List<String> getTenantSpecificExtensionNames()
getTenantSpecificExtensionNames in interface Tenantpublic Locale getTenantSpecificLocale()
getTenantSpecificLocale in interface Tenantpublic TimeZone getTenantSpecificTimeZone()
getTenantSpecificTimeZone in interface Tenantpublic ThreadPool getThreadPool()
getThreadPool in interface Tenantpublic ThreadPool getWorkersThreadPool()
getWorkersThreadPool in interface Tenantpublic JaloSession getActiveSession()
getActiveSession in interface Tenantpublic void deactivateSlaveDataSource()
DataSourceProviderdeactivateSlaveDataSource in interface DataSourceProviderDataSourceProvider.activateSlaveDataSource()public String activateSlaveDataSource()
DataSourceProvider
Tenant t = Registry.getCurrentTenant();
try
{
t.activateSlaveDataSource();
// ... business logic ...
}
finally
{
t.deactivateSlaveSource();
}
activateSlaveDataSource in interface DataSourceProviderDataSourceProvider.deactivateAlternativeDataSource()public void activateSlaveDataSource(String id)
DataSourceProvider
Tenant t = Registry.getCurrentTenant();
try
{
t.activateSlaveDataSource("your_slave_id");
// ... business logic ...
}
finally
{
t.deactivateSlaveSource();
}
activateSlaveDataSource in interface DataSourceProviderid - the id string of the slave data sourceDataSourceProvider.deactivateAlternativeDataSource()public HybrisDataSource getMasterDataSource()
DataSourceProvidergetMasterDataSource in interface DataSourceProviderpublic boolean isSlaveDataSource()
DataSourceProviderisSlaveDataSource in interface DataSourceProviderDataSourceProvider is a slave data sourcepublic boolean isAlternativeMasterDataSource()
DataSourceProviderisAlternativeMasterDataSource in interface DataSourceProviderpublic Collection<HybrisDataSource> getAllSlaveDataSources()
DataSourceProvidergetAllSlaveDataSources in interface DataSourceProviderSet with HybrisDataSource objectspublic Set<String> getAllDataSourceIDs()
getAllDataSourceIDs in interface DataSourceProviderpublic void forceMasterDataSource()
DataSourceProviderDataSourceProvider.getDataSource() no matter if a
slave data source has been activated or not.
Please note that this does not affect chosen alternative master data sources. If you want to switch back to the
main master data source use DataSourceProvider.deactivateAlternativeDataSource().forceMasterDataSource in interface DataSourceProviderpublic boolean isForceMaster()
DataSourceProviderDataSourceProvider.forceMasterDataSource() was called then this
method returns true. A DataSourceProvider.deactivateAlternativeDataSource() will reset this state.isForceMaster in interface DataSourceProviderpublic void activateAlternativeMasterDataSource(String id)
DataSourceProvider
Tenant t = Registry.getCurrentTenant();
try
{
t.activateMasterDataSource("your_slave_id");
// ... business logic ...
}
finally
{
t.deactivateSlaveSource();
}
activateAlternativeMasterDataSource in interface DataSourceProviderid - the id string of the slave data sourceDataSourceProvider.deactivateAlternativeDataSource()public void deactivateAlternativeDataSource()
DataSourceProviderdeactivateAlternativeDataSource in interface DataSourceProviderDataSourceProvider.activateSlaveDataSource(),
DataSourceProvider.activateAlternativeMasterDataSource(String)public Set<String> getAllAlternativeMasterDataSourceIDs()
DataSourceProvidergetAllAlternativeMasterDataSourceIDs in interface DataSourceProviderpublic Collection<HybrisDataSource> getAllAlternativeMasterDataSources()
DataSourceProvidergetAllAlternativeMasterDataSources in interface DataSourceProviderSet with HybrisDataSource objectspublic Set<String> getAllSlaveDataSourceIDs()
DataSourceProvidergetAllSlaveDataSourceIDs in interface DataSourceProviderpublic Thread createAndRegisterBackgroundThread(Runnable payload, ThreadFactory factory)
createAndRegisterBackgroundThread in interface TenantCopyright © 2017 SAP SE. All Rights Reserved.