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 void
activateAlternativeMasterDataSource(java.lang.String id)
Switches to a specified (by the id) master data source for the current thread.java.lang.String
activateSlaveDataSource()
Switches to a slave data source for the current thread.void
activateSlaveDataSource(java.lang.String id)
Switches to a specified (by the id) slave data source for the current thread.java.lang.Thread
createAndRegisterBackgroundThread(java.lang.Runnable payload, java.util.concurrent.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(java.lang.Object object)
void
forceMasterDataSource()
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.JaloSession
getActiveSession()
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.Cache
getCache()
ConfigIntf
getConfig()
HybrisDataSource
getDataSource()
Returns currently active data source.HybrisDataSource
getDataSource(java.lang.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()
java.lang.String
getTenantID()
java.util.List<java.lang.String>
getTenantSpecificExtensionNames()
java.util.Locale
getTenantSpecificLocale()
java.util.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 methodDataSourceProvider.forceMasterDataSource()
was called then this method returns true.boolean
isSlaveDataSource()
Tells whether current data source is a slave data source.void
resetTenantRestartMarker()
-
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:
resetTenantRestartMarker
in interfaceTenant
-
getDataSource
public HybrisDataSource getDataSource(java.lang.String className)
Description copied from interface:DataSourceProvider
Returns new data source. (experimental (related to PLA-7861))- Specified by:
getDataSource
in interfaceDataSourceProvider
-
getConfig
public ConfigIntf getConfig()
-
getDataSource
public HybrisDataSource getDataSource()
Description copied from interface:DataSourceProvider
Returns currently active data source.- Specified by:
getDataSource
in interfaceDataSourceProvider
-
getInvalidationManager
public InvalidationManager getInvalidationManager()
- Specified by:
getInvalidationManager
in interfaceTenant
-
getJaloConnection
public JaloConnection getJaloConnection()
- Specified by:
getJaloConnection
in interfaceTenant
-
getPersistenceManager
public PersistenceManager getPersistenceManager()
- Specified by:
getPersistenceManager
in interfaceTenant
-
getPersistencePool
public PersistencePool getPersistencePool()
- Specified by:
getPersistencePool
in interfaceTenant
-
getSerialNumberGenerator
public SerialNumberGenerator getSerialNumberGenerator()
- Specified by:
getSerialNumberGenerator
in interfaceTenant
-
getSingletonCreator
public SingletonCreator getSingletonCreator()
- Specified by:
getSingletonCreator
in interfaceTenant
-
getSystemEJB
public SystemEJB getSystemEJB()
- Specified by:
getSystemEJB
in interfaceTenant
-
getTenantID
public java.lang.String getTenantID()
- Specified by:
getTenantID
in interfaceTenant
-
getTenantSpecificExtensionNames
public java.util.List<java.lang.String> getTenantSpecificExtensionNames()
- Specified by:
getTenantSpecificExtensionNames
in interfaceTenant
-
getTenantSpecificLocale
public java.util.Locale getTenantSpecificLocale()
- Specified by:
getTenantSpecificLocale
in interfaceTenant
-
getTenantSpecificTimeZone
public java.util.TimeZone getTenantSpecificTimeZone()
- Specified by:
getTenantSpecificTimeZone
in interfaceTenant
-
getThreadPool
public ThreadPool getThreadPool()
- Specified by:
getThreadPool
in interfaceTenant
-
getWorkersThreadPool
public ThreadPool getWorkersThreadPool()
- Specified by:
getWorkersThreadPool
in interfaceTenant
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
getActiveSession
public JaloSession getActiveSession()
- Specified by:
getActiveSession
in interfaceTenant
-
deactivateSlaveDataSource
public void deactivateSlaveDataSource()
Description copied from interface:DataSourceProvider
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).- Specified by:
deactivateSlaveDataSource
in interfaceDataSourceProvider
- See Also:
DataSourceProvider.activateSlaveDataSource()
-
activateSlaveDataSource
public java.lang.String activateSlaveDataSource()
Description copied from interface:DataSourceProvider
Switches 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:
activateSlaveDataSource
in interfaceDataSourceProvider
- See Also:
DataSourceProvider.deactivateAlternativeDataSource()
-
activateSlaveDataSource
public void activateSlaveDataSource(java.lang.String id)
Description copied from interface:DataSourceProvider
Switches 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:
activateSlaveDataSource
in interfaceDataSourceProvider
- Parameters:
id
- the id string of the slave data source- See Also:
DataSourceProvider.deactivateAlternativeDataSource()
-
getMasterDataSource
public HybrisDataSource getMasterDataSource()
Description copied from interface:DataSourceProvider
Returns master data source no matter which one is currently active.- Specified by:
getMasterDataSource
in interfaceDataSourceProvider
-
isSlaveDataSource
public boolean isSlaveDataSource()
Description copied from interface:DataSourceProvider
Tells whether current data source is a slave data source.- Specified by:
isSlaveDataSource
in interfaceDataSourceProvider
- Returns:
- true if the
DataSourceProvider
is a slave data source
-
isAlternativeMasterDataSource
public boolean isAlternativeMasterDataSource()
Description copied from interface:DataSourceProvider
Tells whether the current active data source is a alternative master data source.- Specified by:
isAlternativeMasterDataSource
in interfaceDataSourceProvider
-
getAllSlaveDataSources
public java.util.Collection<HybrisDataSource> getAllSlaveDataSources()
Description copied from interface:DataSourceProvider
Returns all known slave data sources as Collection.- Specified by:
getAllSlaveDataSources
in interfaceDataSourceProvider
- Returns:
- a
Set
withHybrisDataSource
objects
-
getAllDataSourceIDs
public java.util.Set<java.lang.String> getAllDataSourceIDs()
- Specified by:
getAllDataSourceIDs
in interfaceDataSourceProvider
-
forceMasterDataSource
public void forceMasterDataSource()
Description copied from interface:DataSourceProvider
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.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:
forceMasterDataSource
in interfaceDataSourceProvider
-
isForceMaster
public boolean isForceMaster()
Description copied from interface:DataSourceProvider
If 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:
isForceMaster
in interfaceDataSourceProvider
- Returns:
- true if the master data source is forced
-
activateAlternativeMasterDataSource
public void activateAlternativeMasterDataSource(java.lang.String id)
Description copied from interface:DataSourceProvider
Switches 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:
activateAlternativeMasterDataSource
in interfaceDataSourceProvider
- Parameters:
id
- the id string of the slave data source- See Also:
DataSourceProvider.deactivateAlternativeDataSource()
-
deactivateAlternativeDataSource
public void deactivateAlternativeDataSource()
Description copied from interface:DataSourceProvider
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).- Specified by:
deactivateAlternativeDataSource
in interfaceDataSourceProvider
- See Also:
DataSourceProvider.activateSlaveDataSource()
,DataSourceProvider.activateAlternativeMasterDataSource(String)
-
getAllAlternativeMasterDataSourceIDs
public java.util.Set<java.lang.String> getAllAlternativeMasterDataSourceIDs()
Description copied from interface:DataSourceProvider
Provides IDs of all available alternative master data sources.- Specified by:
getAllAlternativeMasterDataSourceIDs
in interfaceDataSourceProvider
-
getAllAlternativeMasterDataSources
public java.util.Collection<HybrisDataSource> getAllAlternativeMasterDataSources()
Description copied from interface:DataSourceProvider
Returns all known alternative master data sources as Collection.- Specified by:
getAllAlternativeMasterDataSources
in interfaceDataSourceProvider
- Returns:
- a
Set
withHybrisDataSource
objects
-
getAllSlaveDataSourceIDs
public java.util.Set<java.lang.String> getAllSlaveDataSourceIDs()
Description copied from interface:DataSourceProvider
Provides IDs of all available slave data sources.- Specified by:
getAllSlaveDataSourceIDs
in interfaceDataSourceProvider
-
createAndRegisterBackgroundThread
public java.lang.Thread createAndRegisterBackgroundThread(java.lang.Runnable payload, java.util.concurrent.ThreadFactory factory)
- Specified by:
createAndRegisterBackgroundThread
in interfaceTenant
-
-