本文整理匯總了Java中org.kie.api.KieServices.newKieBuilder方法的典型用法代碼示例。如果您正苦於以下問題:Java KieServices.newKieBuilder方法的具體用法?Java KieServices.newKieBuilder怎麽用?Java KieServices.newKieBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.kie.api.KieServices
的用法示例。
在下文中一共展示了KieServices.newKieBuilder方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initKie
import org.kie.api.KieServices; //導入方法依賴的package包/類
private void initKie() {
KieServices ks = KieServices.Factory.get();
kfs = ks.newKieFileSystem();
uploadDroolFiles();
KieBuilder kbuilder = ks.newKieBuilder(kfs);
kbuilder.buildAll();
if (kbuilder.getResults().hasMessages(Level.ERROR)) {
throw new IllegalArgumentException(kbuilder.getResults().toString());
}
KieContainer kcontainer = ks.newKieContainer(kbuilder.getKieModule().getReleaseId());
KieBaseConfiguration kbConfig = KieServices.Factory.get().newKieBaseConfiguration();
kbConfig.setOption(ConstraintJittingThresholdOption.get(-1));
kbase = kcontainer.newKieBase(kbConfig);
}
示例2: loadContainerFromString
import org.kie.api.KieServices; //導入方法依賴的package包/類
private KieContainer loadContainerFromString(List<Rule> rules) {
long startTime = System.currentTimeMillis();
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieFileSystem kfs = ks.newKieFileSystem();
for (Rule rule:rules) {
String drl=rule.getContent();
kfs.write("src/main/resources/" + drl.hashCode() + ".drl", drl);
}
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
if (kb.getResults().hasMessages(Message.Level.ERROR)) {
throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
}
long endTime = System.currentTimeMillis();
System.out.println("Time to build rules : " + (endTime - startTime) + " ms" );
startTime = System.currentTimeMillis();
KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
endTime = System.currentTimeMillis();
System.out.println("Time to load container: " + (endTime - startTime) + " ms" );
return kContainer;
}
示例3: createKieContainer
import org.kie.api.KieServices; //導入方法依賴的package包/類
private KieContainer createKieContainer(String... ruleFiles) {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
for (String ruleFile : ruleFiles) {
InputStream ruleFileIs = DroolsTestSupport.class.getResourceAsStream("/" + ruleFile);
Assert.assertNotNull("Can't open stream for rule file. Does it exist?", ruleFileIs);
kfs.write(ks.getResources().newInputStreamResource(ruleFileIs).setSourcePath(ruleFile));
try {
ruleFileIs.close();
} catch (IOException e) {
throw new RuntimeException("InputStream of rule file could not be closed.");
}
}
kieBuilder.buildAll();
StringBuilder message = new StringBuilder();
List<Message> messages = kieBuilder.getResults().getMessages();
for (Message m : messages) {
message.append(m.toString()).append("\n");
}
Assert.assertEquals(message.toString(), 0, messages.size());
return ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
}
示例4: initKieJar
import org.kie.api.KieServices; //導入方法依賴的package包/類
/**
* 初始化一個kjar:把原有的drl包含進新建的kjar中
*
* @param ks
* @param releaseId
* @return
* @throws IOException
*/
public static InternalKieModule initKieJar(KieServices ks, ReleaseId releaseId) throws IOException {
KieFileSystem kfs = createKieFileSystemWithKProject(ks, true);
kfs.writePomXML(getPom(releaseId));
for (File file : getRuleFiles()) {
kfs.write("src/main/resources/" + file.getName(),
ResourceFactory.newClassPathResource(RULES_PATH + File.separator + file.getName(), "UTF-8"));
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {
throw new IllegalStateException("Error creating KieBuilder.");
}
return (InternalKieModule) kieBuilder.getKieModule();
}
示例5: createKieJar
import org.kie.api.KieServices; //導入方法依賴的package包/類
public static InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, ResourceWrapper resourceWrapper) {
KieFileSystem kfs = createKieFileSystemWithKProject(ks, true);
kfs.writePomXML(getPom(releaseId));
kfs.write("src/main/resources/" + resourceWrapper.getTargetResourceName(), resourceWrapper.getResource());
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
if (!kieBuilder.getResults().getMessages().isEmpty()) {
System.out.println(kieBuilder.getResults().getMessages());
throw new IllegalStateException("Error creating KieBuilder.");
}
return (InternalKieModule) kieBuilder.getKieModule();
}
示例6: DecisionTableKieBaseProvider
import org.kie.api.KieServices; //導入方法依賴的package包/類
public DecisionTableKieBaseProvider() {
KieServices kieServices = KieServices.Factory.get();
KieRepository kieRepository = kieServices.getRepository();
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
//addResource(kieFileSystem, "com.redhatbank.brms.tracktrace.model.SLACriteria.gdst");
addResource(kieFileSystem, "org.acme.insurance.TestDS.xls");
KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem);
kieBuilder.buildAll();
for (Message message : kieBuilder.getResults().getMessages()) {
System.out.println(message);
}
kieContainer = kieServices.newKieContainer(kieRepository.getDefaultReleaseId());
}