其他分享
首页 > 其他分享> > 工作流JBPM

工作流JBPM

作者:互联网

public static void main(String[] args) {
        
        //创建流程模板
        ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("helloword/processdefinition.xml");
        
        //创建流程实例
        ProcessInstance processInstance = new ProcessInstance(processDefinition);
        //获取一个流程实例的上下文对象
        //ContextInstance contextInstance =  processInstance.getContextInstance();
        //上下文对象存放临时流程变量和获取同名会覆盖
        //contextInstance.setTransientVariable("", "");   
        //contextInstance.addVariables(variables);
        //根据流程实例创建开始节点的任务实例
        //TaskInstance taskInstance =  processInstance.getTaskMgmtInstance().createStartTaskInstance();
        //向任务实例当中写入先关变量
        //taskInstance.setVariable("money_count", "");
        //结束任务实例流程的Token就进入下一节点
        //taskInstance.end();
        
        
        
        //流程节点
        Token token = processInstance.getRootToken();
        
        Node node = token.getNode();
        
        
        //node节点不会触发
        
        System.out.println(node.getName());
        //节点向下流转一步
        token.signal();
        System.out.println(node.getName());
        
        //判断是否结束
        //token.getProcessInstance().hasEnded();
        
        //单例,线程安全,配置文件对象
        JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
        //主要作用创建jbpmContext上下文对象//发布流程到数据库
        JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
        //从当前线程中获取上下文对象
        //JbpmContext jbpmContext1 = jbpmConfiguration.getCurrentJbpmContext();
        
        //创建数据库表 重新调用会重新创建
        //jbpmConfiguration.createSchema();
        //删除数据库表
        //jbpmConfiguration.dropSchema();
        //获取系统里的任务调度服务对象
        //jbpmConfiguration.getJobExecutor();
        //开始系统的任务调度服务
        //jbpmConfiguration.startJobExecutor();
        //jbpmContext.getTaskList();
        //根据当前人ID获取任务列表
        jbpmContext.getTaskList("");
        //根据任务ID获取任务节点
        TaskInstance instance = jbpmContext.getTaskInstance(11);
        instance.end("同意");
        
        //根据最新的流程名称获取流程模板
        
        //ProcessDefinition lastDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition("helloword");
        
    }
//发布流程模板
        String path = "E:/work/hello.zip";
        
        JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext();
        
        InputStream inputStream = new FileInputStream(new File(path));
        
        ZipInputStream zipInputStream = new ZipInputStream(inputStream);
        
        ProcessDefinition processDefinition = ProcessDefinition.parseParZipInputStream(zipInputStream);
        context.deployProcessDefinition(processDefinition);
        
        zipInputStream.close();
        inputStream.close();
        context.close();

 

标签:JBPM,ProcessDefinition,流程,工作,实例,jbpmContext,jbpmConfiguration,节点
来源: https://www.cnblogs.com/jentary/p/10399034.html