JBPM4.4 使用非zip方式发布流程 实现流程图加载

JBPM4.4 显示流程图片,需要携带流程图发布;这样大多数是采用打包zip方式来部署流程,太过繁琐;所以我采用如下方式发布流程
RepositoryService repositoryService=  processEngine.getRepositoryService();
        NewDeployment deploy= repositoryService.createDeployment();
        deploy.addResourceFromClasspath("newSite.jpdl.xml")
        .addResourceFromClasspath("newSite.png");

action接收processInstanceId,(一般情况下processInstanceId与ExecutionId相同)得到流程图,并在当前activity上画框,来显示流程走到哪里。

public String showImage(){
		ProcessInstance processInstance = executionService  
				.findProcessInstanceById(pid);  
				  
				String processDefinitionId = processInstance.getProcessDefinitionId();  
				ProcessDefinition processDefinition = repositoryService  
				.createProcessDefinitionQuery().processDefinitionId(  
				processDefinitionId).uniqueResult();  
				  
				Set<String> activityNames = processInstance.findActiveActivityNames();  
				BufferedImage image = null;  
				  
				for (String activityName : activityNames) {  
				    ActivityCoordinates ac = repositoryService.getActivityCoordinates(  
				    processInstance.getProcessDefinitionId(), activityName);  
				  
				    InputStream is = repositoryService.getResourceAsStream(  
				    processDefinition.getDeploymentId(), processDefinition  
				    .getImageResourceName());  
				  
				    image = ImageIO.read(is);  
				    Graphics g = image.getGraphics();  
				    g.setColor(new Color(255, 0, 0));  
				  
				    g.drawRect(ac.getX(), ac.getY(), ac.getWidth(), ac.getHeight());  
				    g.dispose();  
				}  
				  
				ByteArrayOutputStream output = new ByteArrayOutputStream();  
				ImageIO.write(image, "PNG", output);  
				ByteArrayInputStream input = new ByteArrayInputStream(output  
				.toByteArray());  
				this.setInputStream(input);  
				return SUCCESS;
	}
structs里面配置result为stream类型,class交给spring处理没有集成的可以修改成原有路径

<action name="processImage" class="processImageAction">  
    <result type="stream">  
        <param name="contentType">image/png</param>  
        <param name="inputName">inputStream</param>  
    </result>  
</action>
jsp页面显示
<img src="processImage.action?pid=<s:property value='id'/>"/>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值