Class NamedDataSourceSelector
- java.lang.Object
-
- com.alibaba.druid.pool.ha.selector.NamedDataSourceSelector
-
- All Implemented Interfaces:
DataSourceSelector
public class NamedDataSourceSelector extends Object implements DataSourceSelector
Use the given name in ThreadLocal variable to choose DataSource.- Author:
- DigitalSonic
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_NAME
-
Constructor Summary
Constructors Constructor Description NamedDataSourceSelector(HighAvailableDataSource highAvailableDataSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Destroy the DataSourceSelector, maybe interrupt the Thread.DataSourceget()Return a DataSource according to the implemention.StringgetDefaultName()StringgetName()Return the name of this DataSourceSelector.StringgetTarget()voidinit()Init the DataSourceSelector before use it.voidresetDataSourceName()voidsetDefaultName(String defaultName)voidsetTarget(String name)Set the target DataSource name to return.
-
-
-
Field Detail
-
DEFAULT_NAME
public static final String DEFAULT_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NamedDataSourceSelector
public NamedDataSourceSelector(HighAvailableDataSource highAvailableDataSource)
-
-
Method Detail
-
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
public String getName()
Description copied from interface:DataSourceSelectorReturn the name of this DataSourceSelector. e.g. byName- Specified by:
getNamein interfaceDataSourceSelector
-
get
public DataSource get()
Description copied from interface:DataSourceSelectorReturn a DataSource according to the implemention.- Specified by:
getin interfaceDataSourceSelector
-
setTarget
public void setTarget(String name)
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
public String getTarget()
-
resetDataSourceName
public void resetDataSourceName()
-
getDefaultName
public String getDefaultName()
-
setDefaultName
public void setDefaultName(String defaultName)
-
-