JBoss 系列三十七:jBPM5示例之 Rule Task

jBPM5中的Rule Task用来执行企业规则文件(drool rules),RuleTask流程示意如下:

JBoss 系列三十七:jBPM5示例之 Rule Task

如上图RuleTask流程只有一个节点Print String Rule,该节点为Rule Task,流程运行时执行ruletaskprocess-rule.drl,ruletaskprocess-rule.drl是输出字符传“Hello World Rule”,内容如下:

package org.jbpm.quickstarts

rule "Hello World Rule" ruleflow-group "Print"
when
	eval( true )
then
	System.out.println("Hello World Rule");
end

  • RuleTask流程运行代码:https://github.com/kylinsoong/.../RuleTaskStart.java
  • RuleTask流程:https://github.com/kylinsoong/.../ruletaskprocess.bpmn
运行org.jbpm.quickstarts.rule.RuleTaskStart将会运行RuleTask流程,RuleTaskStart类内容如下:

package org.jbpm.quickstarts.rule;

import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.quickstarts.QuickStartBase;

public class RuleTaskStart extends QuickStartBase {

	public static void main(String[] args) {
		new RuleTaskStart().test();
	}

	public void test() {
		StatefulKnowledgeSession ksession = createKnowledgeSessionWithDrl("quickstarts/ruletaskprocess-rule.drl", "quickstarts/ruletaskprocess.bpmn");
		ksession.startProcess("org.jbpm.quickstarts.ruletaskprocess");
		ksession.fireAllRules();
		ksession.dispose();
	}

}

RuleTask流程运行输出结果:

Hello World Rule


你可能感兴趣的:(jboss,jbpm,Rule,task,BPM,JBPM5)