Package de.hybris.platform.core
Interface DataSourceProvider
- All Known Subinterfaces:
Tenant
- All Known Implementing Classes:
AbstractTenant,MasterTenant,MockTenant,SlaveTenant,TestSlaveTenantStub,TestTenantStub
public interface DataSourceProvider
Abstraction for tenant to provide access to data source(s).
( This interface has been created for code clarification only - don't use it elsewhere ! )
-
Method Summary
Modifier and TypeMethodDescriptionvoidSwitches to a specified (by the id) master data source for the current thread.Switches to a slave data source for the current thread.voidSwitches to a specified (by the id) slave data source for the current thread.voidAfter 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).voidDeprecated, for removal: This API element is subject to removal in a future version.voidEnforces the usage of a master data source for all subsequent calls togetDataSource()no matter if a slave data source has been activated or not.Provides IDs of all available alternative master data sources.Returns all known alternative master data sources as Collection.Deprecated, for removal: This API element is subject to removal in a future version.since ages - usegetAllSlaveDataSourceIDs()orgetAllAlternativeMasterDataSourceIDs()Provides IDs of all available slave data sources.Returns all known slave data sources as Collection.Returns currently active data source.getDataSource(String className) Returns new data source.Returns master data source no matter which one is currently active.booleanTells whether the current active data source is a alternative master data source.booleanIf on the current data source (slave/master) the methodforceMasterDataSource()was called then this method returns true.booleanTells whether current data source is a slave data source.
-
Method Details
-
getDataSource
Returns new data source. (experimental (related to PLA-7861)) -
getMasterDataSource
HybrisDataSource getMasterDataSource()Returns master data source no matter which one is currently active. -
getDataSource
HybrisDataSource getDataSource()Returns currently active data source. -
isSlaveDataSource
boolean isSlaveDataSource()Tells whether current data source is a slave data source.- Returns:
- true if the
DataSourceProvideris a slave data source
-
isAlternativeMasterDataSource
boolean isAlternativeMasterDataSource()Tells whether the current active data source is a alternative master data source. -
isForceMaster
boolean isForceMaster()If on the current data source (slave/master) the methodforceMasterDataSource()was called then this method returns true. AdeactivateAlternativeDataSource()will reset this state.- Returns:
- true if the master data source is forced
-
activateSlaveDataSource
String activateSlaveDataSource()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(); }- See Also:
-
activateSlaveDataSource
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(); }- Parameters:
id- the id string of the slave data source- Throws:
IllegalArgumentException- if the given id is not configuredIllegalStateException- if the given id was found but cannot connect to given slave data source- See Also:
-
activateAlternativeMasterDataSource
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(); }- Parameters:
id- the id string of the slave data source- Throws:
IllegalArgumentException- if the given id is not configuredIllegalStateException- if the given id was found but cannot connect to given slave data source- See Also:
-
getAllSlaveDataSources
Collection<HybrisDataSource> getAllSlaveDataSources()Returns all known slave data sources as Collection.- Returns:
- a
SetwithHybrisDataSourceobjects
-
getAllAlternativeMasterDataSources
Collection<HybrisDataSource> getAllAlternativeMasterDataSources()Returns all known alternative master data sources as Collection.- Returns:
- a
SetwithHybrisDataSourceobjects
-
getAllDataSourceIDs
Deprecated, for removal: This API element is subject to removal in a future version.since ages - usegetAllSlaveDataSourceIDs()orgetAllAlternativeMasterDataSourceIDs() -
getAllSlaveDataSourceIDs
Provides IDs of all available slave data sources. -
getAllAlternativeMasterDataSourceIDs
Provides IDs of all available alternative master data sources. -
deactivateSlaveDataSource
Deprecated, for removal: This API element is subject to removal in a future version.since ages - usedeactivateAlternativeDataSource()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).- See Also:
-
deactivateAlternativeDataSource
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). -
forceMasterDataSource
void forceMasterDataSource()Enforces the usage of a master data source for all subsequent calls togetDataSource()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
deactivateAlternativeDataSource().
-
deactivateAlternativeDataSource()