ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

activiti修改流程定义二进制数据后需清缓存

2021-03-02 16:59:41  阅读:265  来源: 互联网

标签:engine 缓存 需清 activiti org import resourceEntity commandContext


示例如下

package com.zz.flow.utils;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity;
import java.io.UnsupportedEncodingException;
/**
* 动态更新流程定义
* @author lqx
* @date 2021/3/2 14:51
*/
public class UpdateByteArrayCmd implements Command<Object> {
public UpdateByteArrayCmd() {
}
@Override
public Object execute(CommandContext commandContext) {
String h="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<definitions xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:activiti=\"http://activiti.org/bpmn\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\" xmlns:omgdc=\"http://www.omg.org/spec/DD/20100524/DC\" xmlns:omgdi=\"http://www.omg.org/spec/DD/20100524/DI\" typeLanguage=\"http://www.w3.org/2001/XMLSchema\" expressionLanguage=\"http://www.w3.org/1999/XPath\" targetNamespace=\"http://www.activiti.org/processdef\">" +
" <process id=\"obj1356775660033163265\" isExecutable=\"true\">" +
" <startEvent id=\"sid1612315779740\"/>" +
/*"<userTask id=\"sid1612315819963\" name=\"a\" activiti:assignee=\"${user_sid1612315819963}\">" +
" <multiInstanceLoopCharacteristics isSequential=\"false\" activiti:collection=\"${list_sid1612315819963}\" activiti:elementVariable=\"user_sid1612315819963\"/>" +
" </userTask>"+*/
"<userTask id=\"sid1612315819963\" name=\"a\" activiti:assignee=\"${createUser}\">" +
" </userTask>"+
" <sequenceFlow id=\"sid1612315823245\" sourceRef=\"sid1612315779740\" targetRef=\"sid1612315819963\"/>" +
" <parallelGateway id=\"sid1612315819303\"/>" +
" <sequenceFlow id=\"sid1612315851310\" sourceRef=\"sid1612315819963\" targetRef=\"sid1612315819303\"/>" +
" <userTask id=\"sid1612315794587\" name=\"b\" activiti:assignee=\"${user_sid1612315794587}\">" +
" <multiInstanceLoopCharacteristics isSequential=\"false\" activiti:collection=\"${list_sid1612315794587}\" activiti:elementVariable=\"user_sid1612315794587\"/>" +
" </userTask>" +
" <sequenceFlow id=\"sid1612315797380\" sourceRef=\"sid1612315819303\" targetRef=\"sid1612315794587\"/>" +
" <userTask id=\"sid1612315784629\" name=\"c\" activiti:assignee=\"${user_sid1612315784629}\"/>" +
" <sequenceFlow id=\"sid1612315837016\" sourceRef=\"sid1612315819303\" targetRef=\"sid1612315784629\"/>" +
" <parallelGateway id=\"sid1612315856360\"/>" +
" <userTask id=\"sid1612315785641\" name=\"e\" activiti:assignee=\"${user_sid1612315785641}\"/>" +
" <sequenceFlow id=\"sid1612315808969\" sourceRef=\"sid1612315856360\" targetRef=\"sid1612315785641\"/>" +
" <userTask id=\"sid1612315774748\" name=\"d\" activiti:assignee=\"${user_sid1612315774748}\"/>" +
" <sequenceFlow id=\"sid1612315834465\" sourceRef=\"sid1612315856360\" targetRef=\"sid1612315774748\"/>" +
" <sequenceFlow id=\"sid1612315801477\" sourceRef=\"sid1612315794587\" targetRef=\"sid1612315856360\"/>" +
" <parallelGateway id=\"sid1612315797069\"/>" +
" <sequenceFlow id=\"sid1612315802306\" sourceRef=\"sid1612315785641\" targetRef=\"sid1612315797069\"/>" +
" <sequenceFlow id=\"sid1612315759794\" sourceRef=\"sid1612315774748\" targetRef=\"sid1612315797069\"/>" +
" <userTask id=\"sid1612315811783\" name=\"f\" activiti:assignee=\"${user_sid1612315811783}\"/>" +
" <sequenceFlow id=\"sid1612315788209\" sourceRef=\"sid1612315797069\" targetRef=\"sid1612315811783\"/>" +
" <parallelGateway id=\"sid1612315765072\"/>" +
" <sequenceFlow id=\"sid1612315794022\" sourceRef=\"sid1612315784629\" targetRef=\"sid1612315765072\"/>" +
" <sequenceFlow id=\"sid1612315790937\" sourceRef=\"sid1612315811783\" targetRef=\"sid1612315765072\"/>" +
" <userTask id=\"sid1612315851207\" name=\"g\" activiti:assignee=\"${user_sid1612315851207}\"/>" +
" <sequenceFlow id=\"sid1612315839669\" sourceRef=\"sid1612315765072\" targetRef=\"sid1612315851207\"/>" +
" <endEvent id=\"sid1612315822608\"/>" +
" <sequenceFlow id=\"sid1612315801380\" sourceRef=\"sid1612315851207\" targetRef=\"sid1612315822608\"/>" +
" </process>" +
" <bpmndi:BPMNDiagram id=\"BPMNDiagram_obj1356775660033163265\">" +
" <bpmndi:BPMNPlane bpmnElement=\"obj1356775660033163265\" id=\"BPMNPlane_obj1356775660033163265\">" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315779740\" id=\"BPMNShape_sid1612315779740\">" +
" <omgdc:Bounds height=\"30.0\" width=\"30.0\" x=\"162.06668090820312\" y=\"101.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315819963\" id=\"BPMNShape_sid1612315819963\">" +
" <omgdc:Bounds height=\"80.0\" width=\"100.0\" x=\"237.06668090820312\" y=\"76.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315819303\" id=\"BPMNShape_sid1612315819303\">" +
" <omgdc:Bounds height=\"40.0\" width=\"40.0\" x=\"398.0666809082031\" y=\"94.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315794587\" id=\"BPMNShape_sid1612315794587\">" +
" <omgdc:Bounds height=\"80.0\" width=\"100.0\" x=\"480.0\" y=\"15.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315784629\" id=\"BPMNShape_sid1612315784629\">" +
" <omgdc:Bounds height=\"80.0\" width=\"100.0\" x=\"483.0666809082031\" y=\"195.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315856360\" id=\"BPMNShape_sid1612315856360\">" +
" <omgdc:Bounds height=\"40.0\" width=\"40.0\" x=\"675.0\" y=\"40.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315785641\" id=\"BPMNShape_sid1612315785641\">" +
" <omgdc:Bounds height=\"80.0\" width=\"100.0\" x=\"825.0\" y=\"0.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315774748\" id=\"BPMNShape_sid1612315774748\">" +
" <omgdc:Bounds height=\"80.0\" width=\"100.0\" x=\"735.0\" y=\"105.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315797069\" id=\"BPMNShape_sid1612315797069\">" +
" <omgdc:Bounds height=\"40.0\" width=\"40.0\" x=\"1011.5666667222977\" y=\"109.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315811783\" id=\"BPMNShape_sid1612315811783\">" +
" <omgdc:Bounds height=\"80.0\" width=\"100.0\" x=\"1020.0\" y=\"180.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315765072\" id=\"BPMNShape_sid1612315765072\">" +
" <omgdc:Bounds height=\"40.0\" width=\"40.0\" x=\"782.4833335876465\" y=\"228.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315851207\" id=\"BPMNShape_sid1612315851207\">" +
" <omgdc:Bounds height=\"80.0\" width=\"100.0\" x=\"810.0\" y=\"285.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNShape bpmnElement=\"sid1612315822608\" id=\"BPMNShape_sid1612315822608\">" +
" <omgdc:Bounds height=\"28.0\" width=\"28.0\" x=\"955.0\" y=\"311.0\"/>" +
" </bpmndi:BPMNShape>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315759794\" id=\"BPMNEdge_sid1612315759794\">" +
" <omgdi:waypoint x=\"835.0\" y=\"141.75544139589226\"/>" +
" <omgdi:waypoint x=\"1012.7854048203002\" y=\"130.21873809800255\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315788209\" id=\"BPMNEdge_sid1612315788209\">" +
" <omgdi:waypoint x=\"1051.0666667222977\" y=\"129.5\"/>" +
" <omgdi:waypoint x=\"1070.0\" y=\"129.5\"/>" +
" <omgdi:waypoint x=\"1070.0\" y=\"180.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315802306\" id=\"BPMNEdge_sid1612315802306\">" +
" <omgdi:waypoint x=\"925.0\" y=\"68.4223972647573\"/>" +
" <omgdi:waypoint x=\"1018.8152075106651\" y=\"121.75145921163259\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315797380\" id=\"BPMNEdge_sid1612315797380\">" +
" <omgdi:waypoint x=\"418.5666809082031\" y=\"94.5\"/>" +
" <omgdi:waypoint x=\"418.5666809082031\" y=\"55.0\"/>" +
" <omgdi:waypoint x=\"480.0\" y=\"55.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315851310\" id=\"BPMNEdge_sid1612315851310\">" +
" <omgdi:waypoint x=\"337.0666809082031\" y=\"115.23664122137404\"/>" +
" <omgdi:waypoint x=\"398.3674327879024\" y=\"114.30075187969925\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315839669\" id=\"BPMNEdge_sid1612315839669\">" +
" <omgdi:waypoint x=\"821.9833335876465\" y=\"248.5\"/>" +
" <omgdi:waypoint x=\"860.0\" y=\"248.5\"/>" +
" <omgdi:waypoint x=\"860.0\" y=\"285.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315837016\" id=\"BPMNEdge_sid1612315837016\">" +
" <omgdi:waypoint x=\"437.5666809082031\" y=\"114.5\"/>" +
" <omgdi:waypoint x=\"533.0666809082031\" y=\"114.5\"/>" +
" <omgdi:waypoint x=\"533.0666809082031\" y=\"195.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315794022\" id=\"BPMNEdge_sid1612315794022\">" +
" <omgdi:waypoint x=\"583.0666809082031\" y=\"237.41261998297256\"/>" +
" <omgdi:waypoint x=\"783.4039591865028\" y=\"247.07937440114372\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315801380\" id=\"BPMNEdge_sid1612315801380\">" +
" <omgdi:waypoint x=\"910.0\" y=\"325.0\"/>" +
" <omgdi:waypoint x=\"955.0\" y=\"325.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315834465\" id=\"BPMNEdge_sid1612315834465\">" +
" <omgdi:waypoint x=\"714.5\" y=\"60.5\"/>" +
" <omgdi:waypoint x=\"785.0\" y=\"60.5\"/>" +
" <omgdi:waypoint x=\"785.0\" y=\"105.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315808969\" id=\"BPMNEdge_sid1612315808969\">" +
" <omgdi:waypoint x=\"714.5\" y=\"60.5\"/>" +
" <omgdi:waypoint x=\"770.0\" y=\"60.5\"/>" +
" <omgdi:waypoint x=\"770.0\" y=\"40.0\"/>" +
" <omgdi:waypoint x=\"825.0\" y=\"40.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315801477\" id=\"BPMNEdge_sid1612315801477\">" +
" <omgdi:waypoint x=\"580.0\" y=\"55.0\"/>" +
" <omgdi:waypoint x=\"680.0\" y=\"55.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315823245\" id=\"BPMNEdge_sid1612315823245\">" +
" <omgdi:waypoint x=\"192.06668090820312\" y=\"116.0\"/>" +
" <omgdi:waypoint x=\"237.06668090820312\" y=\"116.0\"/>" +
" </bpmndi:BPMNEdge>" +
" <bpmndi:BPMNEdge bpmnElement=\"sid1612315790937\" id=\"BPMNEdge_sid1612315790937\">" +
" <omgdi:waypoint x=\"1020.0\" y=\"225.2333188013117\"/>" +
" <omgdi:waypoint x=\"820.5883474036233\" y=\"246.1050138159768\"/>" +
" </bpmndi:BPMNEdge>" +
" </bpmndi:BPMNPlane>" +
" </bpmndi:BPMNDiagram>" +
"</definitions>";
try {
ByteArrayEntity resourceEntity = new ByteArrayEntity(h.getBytes("UTF-8"));
resourceEntity.setId("obj1356889910785433603");
resourceEntity.setRevision(6);
commandContext.getDbSqlSession().update(resourceEntity);
//清除缓存
commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().clear();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
}

调用如下

@Resource
private ManagementService managementService;

//controller中如下

managementService.executeCommand(new UpdateByteArrayCmd())

 

标签:engine,缓存,需清,activiti,org,import,resourceEntity,commandContext
来源: https://blog.csdn.net/qi923701/article/details/114288898

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有