You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
1 year ago
|
package com.fr.design.lock;
|
||
|
|
||
|
import com.fr.design.file.HistoryTemplateListCache;
|
||
|
import com.fr.design.mainframe.JTemplate;
|
||
|
import com.fr.event.Event;
|
||
|
import com.fr.event.EventDispatcher;
|
||
|
import com.fr.event.Listener;
|
||
|
import com.fr.log.FineLoggerFactory;
|
||
|
import com.fr.report.lock.LockInfoOperator;
|
||
|
import com.fr.stable.collections.CollectionUtils;
|
||
|
import com.fr.workspace.WorkContext;
|
||
|
import com.fr.workspace.Workspace;
|
||
|
import com.fr.workspace.WorkspaceEvent;
|
||
|
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* 更新模板锁信息
|
||
|
*
|
||
|
* @author Roger
|
||
|
* @since 11.0
|
||
|
* Created on 2023/12/11
|
||
|
*/
|
||
|
public class TemplateLockInfoReSave {
|
||
|
|
||
|
/**
|
||
|
* 启动监听
|
||
|
*/
|
||
|
public static void startListener() {
|
||
|
if (!WorkContext.getCurrent().isLocal()) {
|
||
|
EventDispatcher.listen(WorkspaceEvent.ReConnectSuccess, new Listener<Workspace>() {
|
||
|
@Override
|
||
|
public void on(Event event, Workspace workspace) {
|
||
|
List<JTemplate<?, ?>> templates = HistoryTemplateListCache.getInstance().getHistoryList();
|
||
|
if (CollectionUtils.isEmpty(templates)) {
|
||
|
return;
|
||
|
}
|
||
|
String[] paths = templates.stream().map(JTemplate::getPath).toArray(String[]::new);
|
||
|
String[] lockedPath = WorkContext.getCurrent().get(LockInfoOperator.class).lockTemplates(paths);
|
||
|
FineLoggerFactory.getLogger().warn("template lock failed:{}", String.join(";", lockedPath));
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|