droolstest.java.template

来自「drools 一个开放源码的规则引擎」· TEMPLATE 代码 · 共 33 行

TEMPLATE
33
字号
package com.sample;

import org.drools.RuleBase;
import org.drools.WorkingMemory;
import org.drools.io.RuleBaseLoader;

public class DroolsTest {

    public static final void main(String[] args) {
        try {
        	// loading rule file rules.java.drl
            RuleBase ruleBase = RuleBaseLoader.loadFromInputStream(
                DroolsTest.class.getResourceAsStream("/Rules.java.drl"));
            
            // creating working memory
            WorkingMemory workingMemory = ruleBase.newWorkingMemory();
            
            // insert elements in the working memory here
            // e.g. workingMemory.assertObject(new Integer(10));
            
            // Set application data here
			// e.g. workingMemory.setApplicationData("myApplicationDataName", 12);
			
            // firing all rules
            workingMemory.fireAllRules();
            
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?