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();
通过类名反射获取事实实例
猜你喜欢
转载自duyangsss.iteye.com/blog/2034093
今日推荐
周排行