EntityInfo
This commit is contained in:
@@ -37,8 +37,6 @@ public final class EntityInfo<T> {
|
|||||||
// 全局静态资源
|
// 全局静态资源
|
||||||
private static final ConcurrentHashMap<Class, EntityInfo> entityInfos = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<Class, EntityInfo> entityInfos = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private static final ReentrantLock infosLock = new ReentrantLock();
|
|
||||||
|
|
||||||
// 日志
|
// 日志
|
||||||
private static final Logger logger = Logger.getLogger(EntityInfo.class.getSimpleName());
|
private static final Logger logger = Logger.getLogger(EntityInfo.class.getSimpleName());
|
||||||
|
|
||||||
@@ -218,27 +216,13 @@ public final class EntityInfo<T> {
|
|||||||
final Properties conf,
|
final Properties conf,
|
||||||
DataSource source,
|
DataSource source,
|
||||||
BiFunction<DataSource, EntityInfo, CompletableFuture<List>> fullloader) {
|
BiFunction<DataSource, EntityInfo, CompletableFuture<List>> fullloader) {
|
||||||
EntityInfo rs = entityInfos.get(clazz);
|
return entityInfos.computeIfAbsent(clazz, clz -> {
|
||||||
if (rs != null && (rs.cache == null || rs.cache.isFullLoaded())) {
|
EntityInfo rs = new EntityInfo(clz, cacheForbidden, conf, source, fullloader);
|
||||||
return rs;
|
if (rs.cache != null) {
|
||||||
}
|
|
||||||
infosLock.lock();
|
|
||||||
try {
|
|
||||||
rs = entityInfos.get(clazz);
|
|
||||||
if (rs == null) {
|
|
||||||
rs = new EntityInfo(clazz, cacheForbidden, conf, source, fullloader);
|
|
||||||
entityInfos.put(clazz, rs);
|
|
||||||
}
|
|
||||||
if (rs.cache != null && !rs.isCacheFullLoaded()) {
|
|
||||||
if (fullloader == null) {
|
|
||||||
throw new IllegalArgumentException(clazz.getName() + " auto loader is illegal");
|
|
||||||
}
|
|
||||||
rs.cache.fullLoadAsync();
|
rs.cache.fullLoadAsync();
|
||||||
}
|
}
|
||||||
return rs;
|
return rs;
|
||||||
} finally {
|
});
|
||||||
infosLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user