|
|
@ -445,16 +445,15 @@ public class HistoryTemplateListCache implements CallbackEvent { |
|
|
|
int size = historyList.size(); |
|
|
|
int size = historyList.size(); |
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
JTemplate<?, ?> template = historyList.get(i); |
|
|
|
JTemplate<?, ?> template = historyList.get(i); |
|
|
|
|
|
|
|
// 判断刷新逻辑比较耗时,且可能出现插件安装后误判导致不刷新
|
|
|
|
|
|
|
|
// 插件安装/启用场景比较少,因此插件安装/启用后每次均进行刷新
|
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
boolean needReload = context == null || needReloadTemplate(context, template); |
|
|
|
|
|
|
|
if (needReload) { |
|
|
|
|
|
|
|
FILE stashFile = template.templateToStashFile(); |
|
|
|
FILE stashFile = template.templateToStashFile(); |
|
|
|
if (stashFile != null) { |
|
|
|
if (stashFile != null) { |
|
|
|
FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); |
|
|
|
FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); |
|
|
|
template.refreshResource(stashFile); |
|
|
|
template.refreshResource(stashFile); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().info("Plugin env change reload all template ended"); |
|
|
|
FineLoggerFactory.getLogger().info("Plugin env change reload all template ended"); |
|
|
|
FineLoggerFactory.getLogger().info("Reload all template spend: {} ms", (System.currentTimeMillis() - start)); |
|
|
|
FineLoggerFactory.getLogger().info("Reload all template spend: {} ms", (System.currentTimeMillis() - start)); |
|
|
|
} |
|
|
|
} |
|
|
@ -474,28 +473,6 @@ public class HistoryTemplateListCache implements CallbackEvent { |
|
|
|
_reloadAllEditingTemplate(null); |
|
|
|
_reloadAllEditingTemplate(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean needReloadTemplate(PluginContext context, JTemplate<?, ?> template) { |
|
|
|
|
|
|
|
BaseBook baseBook = template.getTarget(); |
|
|
|
|
|
|
|
if (baseBook != null) { |
|
|
|
|
|
|
|
String name = template.getEditingFILE().getName(); |
|
|
|
|
|
|
|
String pluginId = context.getID(); |
|
|
|
|
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
|
|
|
|
Set<ClassLoader> set = ClassHelper.getClassLoadersByFilter(baseBook, ClassFilter.getInstance()); |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().info("{} find plugin classloader spend: {} ms", name, (System.currentTimeMillis() - start)); |
|
|
|
|
|
|
|
if (set != null) { |
|
|
|
|
|
|
|
for (ClassLoader classLoader : set) { |
|
|
|
|
|
|
|
if (ComparatorUtils.equals(pluginId, PluginManager.detectLeakingPlugin(classLoader))) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// set为null说明 检测classloader 这里返回true直接刷新 兜底行为
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void replaceCurrentEditingTemplate(JTemplate<?, ?> jt) { |
|
|
|
public void replaceCurrentEditingTemplate(JTemplate<?, ?> jt) { |
|
|
|
int index = contains(this.editingTemplate); |
|
|
|
int index = contains(this.editingTemplate); |
|
|
|
this.editingTemplate = jt; |
|
|
|
this.editingTemplate = jt; |
|
|
|