Package de.hybris.platform.core
Interface DataSourceProvider
-
- All Known Subinterfaces:
Tenant
- All Known Implementing Classes:
AbstractTenant,MasterTenant,MockTenant,SlaveTenant,TestSlaveTenantStub,TestTenantStub
public interface DataSourceProviderAbstraction 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
All Methods Instance Methods Abstract Methods Deprecated 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.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()Deprecated.since ages - usedeactivateAlternativeDataSource()voidforceMasterDataSource()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.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()Deprecated.since ages - usegetAllSlaveDataSourceIDs()orgetAllAlternativeMasterDataSourceIDs()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.HybrisDataSourcegetDataSource()Returns currently active data source.HybrisDataSourcegetDataSource(java.lang.String className)Returns new data source.HybrisDataSourcegetMasterDataSource()Returns master data source no matter which one is currently active.booleanisAlternativeMasterDataSource()Tells whether the current active data source is a alternative master data source.booleanisForceMaster()If on the current data source (slave/master) the methodforceMasterDataSource()was called then this method returns true.booleanisSlaveDataSource()Tells whether current data source is a slave data source.
-
-
-
Method Detail
-
getDataSource
HybrisDataSource getDataSource(java.lang.String className)
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
java.lang.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:
deactivateAlternativeDataSource()
-
activateSlaveDataSource
void activateSlaveDataSource(java.lang.String id)
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:
java.lang.IllegalArgumentException- if the given id is not configuredjava.lang.IllegalStateException- if the given id was found but cannot connect to given slave data source- See Also:
deactivateAlternativeDataSource()
-
activateAlternativeMasterDataSource
void activateAlternativeMasterDataSource(java.lang.String id)
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:
java.lang.IllegalArgumentException- if the given id is not configuredjava.lang.IllegalStateException- if the given id was found but cannot connect to given slave data source- See Also:
deactivateAlternativeDataSource()
-
getAllSlaveDataSources
java.util.Collection<HybrisDataSource> getAllSlaveDataSources()
Returns all known slave data sources as Collection.- Returns:
- a
SetwithHybrisDataSourceobjects
-
getAllAlternativeMasterDataSources
java.util.Collection<HybrisDataSource> getAllAlternativeMasterDataSources()
Returns all known alternative master data sources as Collection.- Returns:
- a
SetwithHybrisDataSourceobjects
-
getAllDataSourceIDs
@Deprecated java.util.Set<java.lang.String> getAllDataSourceIDs()
Deprecated.since ages - usegetAllSlaveDataSourceIDs()orgetAllAlternativeMasterDataSourceIDs()
-
getAllSlaveDataSourceIDs
java.util.Set<java.lang.String> getAllSlaveDataSourceIDs()
Provides IDs of all available slave data sources.
-
getAllAlternativeMasterDataSourceIDs
java.util.Set<java.lang.String> getAllAlternativeMasterDataSourceIDs()
Provides IDs of all available alternative master data sources.
-
deactivateSlaveDataSource
@Deprecated void deactivateSlaveDataSource()
Deprecated.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:
activateSlaveDataSource()
-
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().
-
-