Class MockTenant
- java.lang.Object
-
- de.hybris.platform.servicelayer.tenant.MockTenant
-
- All Implemented Interfaces:
DataSourceProvider,Tenant
public class MockTenant extends java.lang.Object implements Tenant
-
-
Constructor Summary
Constructors Constructor Description MockTenant(java.lang.String tenantId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateAlternativeMasterDataSource(java.lang.String id)Switches to a specified (by the id) master data source for the current thread.java.lang.StringactivateSlaveDataSource()Switches to a slave data source for the current thread.voidactivateSlaveDataSource(java.lang.String id)Switches to a specified (by the id) slave data source for the current thread.java.lang.ThreadcreateAndRegisterBackgroundThread(java.lang.Runnable payload, java.util.concurrent.ThreadFactory factory)voiddeactivateAlternativeDataSource()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).voiddeactivateSlaveDataSource()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).booleanequals(java.lang.Object object)voidforceMasterDataSource()Enforces the usage of a master data source for all subsequent calls toDataSourceProvider.getDataSource()no matter if a slave data source has been activated or not.JaloSessiongetActiveSession()java.util.Set<java.lang.String>getAllAlternativeMasterDataSourceIDs()Provides IDs of all available alternative master data sources.java.util.Collection<HybrisDataSource>getAllAlternativeMasterDataSources()Returns all known alternative master data sources as Collection.java.util.Set<java.lang.String>getAllDataSourceIDs()java.util.Set<java.lang.String>getAllSlaveDataSourceIDs()Provides IDs of all available slave data sources.java.util.Collection<HybrisDataSource>getAllSlaveDataSources()Returns all known slave data sources as Collection.CachegetCache()ConfigIntfgetConfig()HybrisDataSourcegetDataSource()Returns currently active data source.HybrisDataSourcegetDataSource(java.lang.String className)Returns new data source.InvalidationManagergetInvalidationManager()JaloConnectiongetJaloConnection()HybrisDataSourcegetMasterDataSource()Returns master data source no matter which one is currently active.PersistenceManagergetPersistenceManager()PersistencePoolgetPersistencePool()SerialNumberGeneratorgetSerialNumberGenerator()SingletonCreatorgetSingletonCreator()SystemEJBgetSystemEJB()java.lang.StringgetTenantID()java.util.List<java.lang.String>getTenantSpecificExtensionNames()java.util.LocalegetTenantSpecificLocale()java.util.TimeZonegetTenantSpecificTimeZone()ThreadPoolgetThreadPool()ThreadPoolgetWorkersThreadPool()inthashCode()booleanisAlternativeMasterDataSource()Tells whether the current active data source is a alternative master data source.booleanisForceMaster()If on the current data source (slave/master) the methodDataSourceProvider.forceMasterDataSource()was called then this method returns true.booleanisSlaveDataSource()Tells whether current data source is a slave data source.voidresetTenantRestartMarker()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.core.Tenant
getAllItemLifecycleListeners
-
-
-
-
Method Detail
-
resetTenantRestartMarker
public void resetTenantRestartMarker()
- Specified by:
resetTenantRestartMarkerin interfaceTenant
-
getDataSource
public HybrisDataSource getDataSource(java.lang.String className)
Description copied from interface:DataSourceProviderReturns new data source. (experimental (related to PLA-7861))- Specified by:
getDataSourcein interfaceDataSourceProvider
-
getConfig
public ConfigIntf getConfig()
-
getDataSource
public HybrisDataSource getDataSource()
Description copied from interface:DataSourceProviderReturns currently active data source.- Specified by:
getDataSourcein interfaceDataSourceProvider
-
getInvalidationManager
public InvalidationManager getInvalidationManager()
- Specified by:
getInvalidationManagerin interfaceTenant
-
getJaloConnection
public JaloConnection getJaloConnection()
- Specified by:
getJaloConnectionin interfaceTenant
-
getPersistenceManager
public PersistenceManager getPersistenceManager()
- Specified by:
getPersistenceManagerin interfaceTenant
-
getPersistencePool
public PersistencePool getPersistencePool()
- Specified by:
getPersistencePoolin interfaceTenant
-
getSerialNumberGenerator
public SerialNumberGenerator getSerialNumberGenerator()
- Specified by:
getSerialNumberGeneratorin interfaceTenant
-
getSingletonCreator
public SingletonCreator getSingletonCreator()
- Specified by:
getSingletonCreatorin interfaceTenant
-
getSystemEJB
public SystemEJB getSystemEJB()
- Specified by:
getSystemEJBin interfaceTenant
-
getTenantID
public java.lang.String getTenantID()
- Specified by:
getTenantIDin interfaceTenant
-
getTenantSpecificExtensionNames
public java.util.List<java.lang.String> getTenantSpecificExtensionNames()
- Specified by:
getTenantSpecificExtensionNamesin interfaceTenant
-
getTenantSpecificLocale
public java.util.Locale getTenantSpecificLocale()
- Specified by:
getTenantSpecificLocalein interfaceTenant
-
getTenantSpecificTimeZone
public java.util.TimeZone getTenantSpecificTimeZone()
- Specified by:
getTenantSpecificTimeZonein interfaceTenant
-
getThreadPool
public ThreadPool getThreadPool()
- Specified by:
getThreadPoolin interfaceTenant
-
getWorkersThreadPool
public ThreadPool getWorkersThreadPool()
- Specified by:
getWorkersThreadPoolin interfaceTenant
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
getActiveSession
public JaloSession getActiveSession()
- Specified by:
getActiveSessionin interfaceTenant
-
deactivateSlaveDataSource
public void deactivateSlaveDataSource()
Description copied from interface:DataSourceProviderAfter 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).- Specified by:
deactivateSlaveDataSourcein interfaceDataSourceProvider- See Also:
DataSourceProvider.activateSlaveDataSource()
-
activateSlaveDataSource
public java.lang.String activateSlaveDataSource()
Description copied from interface:DataSourceProviderSwitches to a slave data source for the current thread. If the current data source is already a slave one this has no effect. Use as follows:Tenant t = Registry.getCurrentTenant(); try { t.activateSlaveDataSource(); // ... business logic ... } finally { t.deactivateSlaveSource(); }- Specified by:
activateSlaveDataSourcein interfaceDataSourceProvider- See Also:
DataSourceProvider.deactivateAlternativeDataSource()
-
activateSlaveDataSource
public void activateSlaveDataSource(java.lang.String id)
Description copied from interface:DataSourceProviderSwitches to a specified (by the id) slave data source for the current thread. If the current data source is already a slave one this has no effect. Use as follows:Tenant t = Registry.getCurrentTenant(); try { t.activateSlaveDataSource("your_slave_id"); // ... business logic ... } finally { t.deactivateSlaveSource(); }- Specified by:
activateSlaveDataSourcein interfaceDataSourceProvider- Parameters:
id- the id string of the slave data source- See Also:
DataSourceProvider.deactivateAlternativeDataSource()
-
getMasterDataSource
public HybrisDataSource getMasterDataSource()
Description copied from interface:DataSourceProviderReturns master data source no matter which one is currently active.- Specified by:
getMasterDataSourcein interfaceDataSourceProvider
-
isSlaveDataSource
public boolean isSlaveDataSource()
Description copied from interface:DataSourceProviderTells whether current data source is a slave data source.- Specified by:
isSlaveDataSourcein interfaceDataSourceProvider- Returns:
- true if the
DataSourceProvideris a slave data source
-
isAlternativeMasterDataSource
public boolean isAlternativeMasterDataSource()
Description copied from interface:DataSourceProviderTells whether the current active data source is a alternative master data source.- Specified by:
isAlternativeMasterDataSourcein interfaceDataSourceProvider
-
getAllSlaveDataSources
public java.util.Collection<HybrisDataSource> getAllSlaveDataSources()
Description copied from interface:DataSourceProviderReturns all known slave data sources as Collection.- Specified by:
getAllSlaveDataSourcesin interfaceDataSourceProvider- Returns:
- a
SetwithHybrisDataSourceobjects
-
getAllDataSourceIDs
public java.util.Set<java.lang.String> getAllDataSourceIDs()
- Specified by:
getAllDataSourceIDsin interfaceDataSourceProvider
-
forceMasterDataSource
public void forceMasterDataSource()
Description copied from interface:DataSourceProviderEnforces the usage of a master data source for all subsequent calls toDataSourceProvider.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().- Specified by:
forceMasterDataSourcein interfaceDataSourceProvider
-
isForceMaster
public boolean isForceMaster()
Description copied from interface:DataSourceProviderIf on the current data source (slave/master) the methodDataSourceProvider.forceMasterDataSource()was called then this method returns true. ADataSourceProvider.deactivateAlternativeDataSource()will reset this state.- Specified by:
isForceMasterin interfaceDataSourceProvider- Returns:
- true if the master data source is forced
-
activateAlternativeMasterDataSource
public void activateAlternativeMasterDataSource(java.lang.String id)
Description copied from interface:DataSourceProviderSwitches to a specified (by the id) master data source for the current thread. Use as follows:Tenant t = Registry.getCurrentTenant(); try { t.activateMasterDataSource("your_slave_id"); // ... business logic ... } finally { t.deactivateSlaveSource(); }- Specified by:
activateAlternativeMasterDataSourcein interfaceDataSourceProvider- Parameters:
id- the id string of the slave data source- See Also:
DataSourceProvider.deactivateAlternativeDataSource()
-
deactivateAlternativeDataSource
public void deactivateAlternativeDataSource()
Description copied from interface:DataSourceProviderAfter 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).- Specified by:
deactivateAlternativeDataSourcein interfaceDataSourceProvider- See Also:
DataSourceProvider.activateSlaveDataSource(),DataSourceProvider.activateAlternativeMasterDataSource(String)
-
getAllAlternativeMasterDataSourceIDs
public java.util.Set<java.lang.String> getAllAlternativeMasterDataSourceIDs()
Description copied from interface:DataSourceProviderProvides IDs of all available alternative master data sources.- Specified by:
getAllAlternativeMasterDataSourceIDsin interfaceDataSourceProvider
-
getAllAlternativeMasterDataSources
public java.util.Collection<HybrisDataSource> getAllAlternativeMasterDataSources()
Description copied from interface:DataSourceProviderReturns all known alternative master data sources as Collection.- Specified by:
getAllAlternativeMasterDataSourcesin interfaceDataSourceProvider- Returns:
- a
SetwithHybrisDataSourceobjects
-
getAllSlaveDataSourceIDs
public java.util.Set<java.lang.String> getAllSlaveDataSourceIDs()
Description copied from interface:DataSourceProviderProvides IDs of all available slave data sources.- Specified by:
getAllSlaveDataSourceIDsin interfaceDataSourceProvider
-
createAndRegisterBackgroundThread
public java.lang.Thread createAndRegisterBackgroundThread(java.lang.Runnable payload, java.util.concurrent.ThreadFactory factory)- Specified by:
createAndRegisterBackgroundThreadin interfaceTenant
-
-