目录
- flowable 清除流程本地缓存
- 一、清除缓存 Cmd
- 二、如何调用
flowable 清除流程本地缓存
flowable 或者 activity 修改流程图属性后,需要清除本地缓存,可以用以下方法来实现。
一、清除缓存 Cmd
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63package indi.tudan.modules.flowable.common.cmd; import indi.tudan.common.core.utils.StringUtils; import org.flowable.common.engine.impl.interceptor.Command; import org.flowable.common.engine.impl.interceptor.CommandContext; import org.flowable.common.engine.impl.persistence.deploy.DeploymentCache; import org.flowable.engine.impl.persistence.deploy.DeploymentManager; import org.flowable.engine.impl.persistence.deploy.ProcessDefinitionCacheEntry; import org.flowable.engine.impl.util.CommandContextUtil; import org.flowable.engine.repository.Deployment; import java.io.Serializable; /** * 清除流程缓存 * * @author wangtan * @date 2021-12-29 10:11:25 * @since 1.0.0 */ public class DeploymentCacheCmd implements Command<Deployment>, Serializable { private static final long serialVersionUID = 1L; private final String definitionId; public DeploymentCacheCmd(String definitionId) { this.definitionId = definitionId; } @Override public Deployment execute(CommandContext commandContext) { DeploymentManager deploymentManager = CommandContextUtil.getProcessEngineConfiguration().getDeploymentManager(); DeploymentCache<ProcessDefinitionCacheEntry> deploymentCache = deploymentManager.getProcessDefinitionCache(); if (StringUtils.isNotBlank(definitionId)) { // 清除指定缓存 deploymentCache.remove(definitionId); } else { // 清除全部缓存 deploymentCache.clear(); } return null; } }dContextUtil.getProcessEngineConfiguration().getDeploymentManager(); DeploymentCache<ProcessDefinitionCacheEntry> deploymentCache = deploymentManager.getProcessDefinitionCache(); deploymentCache.remove(definitionId); return null; } }
其中 StringUtils 参考
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102package indi.tudan.common.core.utils; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * 字符串处理工具类 * * @author wangtan * @date 2019-10-27 13:43:20 * @since 1.0.0 */ public class StringUtils { /** * Don't let anyone else instantiate this class */ private StringUtils() { } /** * 获取字符串 * * @param object 待处理数据 * @return 处理后的字符串 * @date 2019-10-26 17:31:49 */ public static String getStr(Object object) { if (ObjectUtils.isNotNull(object)) { return String.valueOf(object); } else { return ""; } } /** * 字符串是否为空 * * @param cs 字符串 * @return boolean * @date 2019-10-26 17:31:14 */ public static boolean isBlank(CharSequence cs) { int strLen; if (cs != null && (strLen = cs.length()) != 0) { for (int i = 0; i < strLen; ++i) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } } return true; } /** * 字符串是否不为空 * * @param cs 字符串 * @return boolean * @date 2019-10-26 17:31:07 */ public static boolean isNotBlank(CharSequence cs) { return !isBlank(cs); } /** * 若字符串为空,则返回 defaultString * * @param string 字符串 * @param defaultString 默认字符串 * @return String * @author wangtan * @date 2019-09-06 13:53:42 * @since 1.0.0 */ public static String orElse(String string, String defaultString) { return isBlank(string) ? defaultString : string; } /** * 去除所有空白符 * * @param str 字符串 * @return * @date 2020-07-21 19:55:39 * @since 1.0.0 */ public static String replaceBlank(String str) { String dest = null; if (str == null) { return dest; } else { Pattern p = Pattern.compile("\s*|t|r|n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); return dest; } } }
二、如何调用
复制代码
1
2
3
4
5
6
7
8
9
10
11@Autowired protected ManagementService managementService; // 清除某个流程的缓存 // 此处的 xxxxxxxxxxxx 只是示例,请根据实际传流程定义Id managementService.executeCommand(new DeploymentCacheCmd("xxxxxxxxxxxx")); // 清除全部缓存 managementService.executeCommand(new DeploymentCacheCmd(""));
最后
以上就是落寞月饼最近收集整理的关于flowable 清除流程本地缓存flowable 清除流程本地缓存的全部内容,更多相关flowable内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复