Class NamedDataSourceSelector
java.lang.Object
com.alibaba.druid.pool.ha.selector.NamedDataSourceSelector
- All Implemented Interfaces:
DataSourceSelector
Use the given name in ThreadLocal variable to choose DataSource.
- Author:
- DigitalSonic
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroy the DataSourceSelector, maybe interrupt the Thread.get()Return a DataSource according to the implemention.getName()Return the name of this DataSourceSelector.voidinit()Init the DataSourceSelector before use it.voidvoidsetDefaultName(String defaultName) voidSet the target DataSource name to return.
-
Field Details
-
DEFAULT_NAME
- See Also:
-
-
Constructor Details
-
NamedDataSourceSelector
-
-
Method Details
-
init
public void init()Description copied from interface:DataSourceSelectorInit the DataSourceSelector before use it.- Specified by:
initin interfaceDataSourceSelector
-
destroy
public void destroy()Description copied from interface:DataSourceSelectorDestroy the DataSourceSelector, maybe interrupt the Thread.- Specified by:
destroyin interfaceDataSourceSelector
-
getName
Description copied from interface:DataSourceSelectorReturn the name of this DataSourceSelector. e.g. byName- Specified by:
getNamein interfaceDataSourceSelector
-
get
Description copied from interface:DataSourceSelectorReturn a DataSource according to the implemention.- Specified by:
getin interfaceDataSourceSelector
-
setTarget
Description copied from interface:DataSourceSelectorSet the target DataSource name to return. Wether to use this or not, it's decided by the implemention.- Specified by:
setTargetin interfaceDataSourceSelector
-
getTarget
-
resetDataSourceName
public void resetDataSourceName() -
getDefaultName
-
setDefaultName
-