零起点英语Drools6动态读取数据库规则
最近项⽬需要⽤到Drools,以前没接触过的,就只能百度资料了;查到的很多读库的规则写法都是drools6之前的,⽬前发现⼀种写法,只是实现了⾃定义规则,好像只能加载⼀个规则,还有很多问题希望⼤⽜发现解答...
package com.sy.studio.data_rver.dao;
import org.kie.api.KieBa;
import org.kie.api.KieServices;有理数混合运算计算题
ssdbimport org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
conveyer
import org.kie.api.builder.Results;
import org.kie.api.event.rule.DebugAgendaEventListener;
import org.kie.api.event.rule.DebugRuleRuntimeEventListener;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
public class Drools6toDB {
public static void main(String[] args) {
怎么和妹子聊天String rule = "package com.sy\r\n";
rule += "import com.sy.studio.data_rver.dao.Drools6toDB.Message;\r\n";
rule += "rule \"Hello World\"\r\n";
rule += "\twhen\r\n";
rule += "m : Message( status == Message.HELLO, myMessage : message )";
rule += "\tthen\r\n";
秋装搭配技巧
rule += "\t\tSystem.out.println( myMessage );\r\n";
rule += "\t\tm.tMessage(\"Goodbye cruel world\");\r\n";
rule += "\t\tm.tStatus( Message.GOODBYE );;\r\n";
rule += "\t\tupdate( m );;\r\n";
rule += "end\r\n";
rule += "rule \"GoodBye\"\r\n";
rule += "\twhen\r\n";
rule += "Message( status == Message.GOODBYE, myMessage : message )";
rule += "\tthen\r\n";
rule += "\t\tSystem.out.println( 2+\":\"+myMessage );\r\n";
宁少阳
rule += "end\r\n";
KieServices kieServices = ();
KieFileSystem kfs = wKieFileSystem();
kfs.write( "src/main/resources/rules/ruless.drl",Bytes());
KieBuilder kieBuilder = wKieBuilder( kfs ).buildAll();
Results results = Results();
if( results.hasMessages( org.kie.api.builder.Message.Level.ERROR ) ){
System.out.println( Messages() );
throw new IllegalStateException( "### errors ###" );
}
KieContainer kieContainer = wKieContainer( Repository().getDefaultReleaId() );
KieBa kieBa = KieBa();
KieSession kssion = wKieSession();
thick是什么意思Message message = new Message();
message.tMessage("Hello World");
message.tStatus(Message.HELLO);
Message message2 = new Message();
message2.tStatus(Message.HELLO);
message2.tMessage("hi world!");
kssion.addEventListener( new DebugAgendaEventListener() );
kssion.addEventListener( new DebugRuleRuntimeEventListener() );
kssion.inrt(message);
kssion.inrt(message2);
kssion.inrt(message2);
kssion.fireAllRules();
}
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public String getMessage() {
ssage;
}
public void tMessage(String message) { ssage = message;
提出翻译
}
public int getStatus() {
return this.status;
}
public void tStatus(int status) {
this.status = status;
}
}
12yearold小女孩
}