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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Destroy the DataSourceSelector, maybe interrupt the Thread.get()
Return a DataSource according to the implemention.getName()
Return the name of this DataSourceSelector.void
init()
Init the DataSourceSelector before use it.void
void
setDefaultName
(String defaultName) void
Set 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:DataSourceSelector
Init the DataSourceSelector before use it.- Specified by:
init
in interfaceDataSourceSelector
-
destroy
public void destroy()Description copied from interface:DataSourceSelector
Destroy the DataSourceSelector, maybe interrupt the Thread.- Specified by:
destroy
in interfaceDataSourceSelector
-
getName
Description copied from interface:DataSourceSelector
Return the name of this DataSourceSelector. e.g. byName- Specified by:
getName
in interfaceDataSourceSelector
-
get
Description copied from interface:DataSourceSelector
Return a DataSource according to the implemention.- Specified by:
get
in interfaceDataSourceSelector
-
setTarget
Description copied from interface:DataSourceSelector
Set the target DataSource name to return. Wether to use this or not, it's decided by the implemention.- Specified by:
setTarget
in interfaceDataSourceSelector
-
getTarget
-
resetDataSourceName
public void resetDataSourceName() -
getDefaultName
-
setDefaultName
-