public interface DataSourceProvider
( This interface has been created for code clarification only - don't use it elsewhere ! )
| Modifier and Type | Method and 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 - use
deactivateAlternativeDataSource() |
void |
forceMasterDataSource()
Enforces the usage of a master data source for all subsequent calls to
getDataSource() 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 - use
getAllSlaveDataSourceIDs() or getAllAlternativeMasterDataSourceIDs() |
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 method
forceMasterDataSource() was called then this
method returns true. |
boolean |
isSlaveDataSource()
Tells whether current data source is a slave data source.
|
HybrisDataSource getDataSource(java.lang.String className)
HybrisDataSource getMasterDataSource()
HybrisDataSource getDataSource()
boolean isSlaveDataSource()
DataSourceProvider is a slave data sourceboolean isAlternativeMasterDataSource()
boolean isForceMaster()
forceMasterDataSource() was called then this
method returns true. A deactivateAlternativeDataSource() will reset this state.java.lang.String activateSlaveDataSource()
Tenant t = Registry.getCurrentTenant();
try
{
t.activateSlaveDataSource();
// ... business logic ...
}
finally
{
t.deactivateSlaveSource();
}
deactivateAlternativeDataSource()void activateSlaveDataSource(java.lang.String id)
Tenant t = Registry.getCurrentTenant();
try
{
t.activateSlaveDataSource("your_slave_id");
// ... business logic ...
}
finally
{
t.deactivateSlaveSource();
}
id - the id string of the slave data sourcejava.lang.IllegalArgumentException - if the given id is not configuredjava.lang.IllegalStateException - if the given id was found but cannot connect to given slave data sourcedeactivateAlternativeDataSource()void activateAlternativeMasterDataSource(java.lang.String id)
Tenant t = Registry.getCurrentTenant();
try
{
t.activateMasterDataSource("your_slave_id");
// ... business logic ...
}
finally
{
t.deactivateSlaveSource();
}
id - the id string of the slave data sourcejava.lang.IllegalArgumentException - if the given id is not configuredjava.lang.IllegalStateException - if the given id was found but cannot connect to given slave data sourcedeactivateAlternativeDataSource()java.util.Collection<HybrisDataSource> getAllSlaveDataSources()
Set with HybrisDataSource objectsjava.util.Collection<HybrisDataSource> getAllAlternativeMasterDataSources()
Set with HybrisDataSource objects@Deprecated java.util.Set<java.lang.String> getAllDataSourceIDs()
getAllSlaveDataSourceIDs() or getAllAlternativeMasterDataSourceIDs()java.util.Set<java.lang.String> getAllSlaveDataSourceIDs()
java.util.Set<java.lang.String> getAllAlternativeMasterDataSourceIDs()
@Deprecated void deactivateSlaveDataSource()
deactivateAlternativeDataSource()activateSlaveDataSource()void deactivateAlternativeDataSource()
void forceMasterDataSource()
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 deactivateAlternativeDataSource().Copyright © 2018 SAP SE. All Rights Reserved.