com.jn.nacos.plugin.datasource.NacosDatabaseDialectManager Maven / Gradle / Ivy
The newest version!
package com.jn.nacos.plugin.datasource;
import com.alibaba.nacos.common.spi.NacosServiceLoader;
import com.jn.langx.util.collection.Maps;
import java.util.Collection;
import java.util.Map;
public class NacosDatabaseDialectManager {
private Map dialectMap;
private NacosDatabaseDialectManager(){
init();
}
private void init(){
Collection dialects = NacosServiceLoader.load(NacosDatabaseDialect.class);
Map map = Maps.newHashMap();
for (NacosDatabaseDialect dialect : dialects){
map.put(dialect.getName(), dialect);
}
this.dialectMap = map;
}
public NacosDatabaseDialect getDialect(String databaseType){
NacosDatabaseDialect dialect = this.dialectMap.get(databaseType);
if(dialect==null){
dialect = new DefaultNacosDatabaseDialect(databaseType);
}
return dialect;
}
private static final NacosDatabaseDialectManager INSTANCE = new NacosDatabaseDialectManager();
public static NacosDatabaseDialectManager getInstance(){
return INSTANCE;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy