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
All Methods Instance Methods Abstract Methods Deprecated 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.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()
Deprecated.since ages - usedeactivateAlternativeDataSource()
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.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.HybrisDataSource
getDataSource()
Returns currently active data source.HybrisDataSource
getDataSource(java.lang.String className)
Returns new data source.HybrisDataSource
getMasterDataSource()
Returns master data source no matter which one is currently active.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 methodforceMasterDataSource()
was called then this method returns true.boolean
isSlaveDataSource()
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
DataSourceProvider
is 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
Set
withHybrisDataSource
objects
-
getAllAlternativeMasterDataSources
java.util.Collection<HybrisDataSource> getAllAlternativeMasterDataSources()
Returns all known alternative master data sources as Collection.- Returns:
- a
Set
withHybrisDataSource
objects
-
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()
.
-
-