KnowledgeBase kbase = kbuilder.newKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
FactType serverType = Kbase.getFactType("com.going.domain, "User");
Object debianServer = null;
try {
debianServer = serverType.newInstance();
} catch (InstantiationException e) {
System.err.println("the class Server on drools.cookbook.chapter01 package hasn't a constructor");
} catch (IllegalAccessException e) {
System.err.println("unable to access the class Server on drools.cookbook.chapter01 package");
}
serverType.set(debianServer, "name", "duyang");
serverType.set(debianServer, "sex", "male");
serverType.set(debianServer, "telephone", 13198593333);
ksession.insert(debianServer);
ksession.fireAllRules();
通过类名反射获取事实实例
最新推荐文章于 2021-08-10 22:27:03 发布