gu.sql2java.TableManagerProviders Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sql2java-base Show documentation
Show all versions of sql2java-base Show documentation
sql2java common class package
package gu.sql2java;
import java.util.Iterator;
import java.util.ServiceConfigurationError;
import gu.sql2java.utils.SPIUtils;
/**
* @author guyadong
* @since 3.20.0
*/
public class TableManagerProviders {
private static TableManagerProvider instance;
private TableManagerProviders() {
}
/**
* SPI(Service Provider Interface)机制加载 {@link TableManagerProvider}所有实例
*/
private static void loadTableManagerProvider() {
Iterator itor = SPIUtils.serviceLoaderOf(TableManagerProvider.class).iterator();
if(itor.hasNext()){
try {
instance = itor.next();
} catch (ServiceConfigurationError e) {
// 实例初始化失败输出错误日志后继续循环
SimpleLog.log(e.getMessage());
}
}
}
static {
loadTableManagerProvider();
}
public static TableManagerProvider getInstance() {
return instance;
}
}