當前位置: 首頁>>代碼示例>>Java>>正文


Java KieServices.newKieBuilder方法代碼示例

本文整理匯總了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);
}
 
開發者ID:edgexfoundry,項目名稱:support-rulesengine,代碼行數:15,代碼來源:RuleEngine.java

示例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;
}
 
開發者ID:ityouknow,項目名稱:drools-examples,代碼行數:26,代碼來源:ReloadDroolsRulesService.java

示例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());
}
 
開發者ID:jeichler,項目名稱:junit-drools,代碼行數:26,代碼來源:DroolsTestSupport.java

示例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();  
}
 
開發者ID:lansheng228,項目名稱:kie-dynamic-rule,代碼行數:22,代碼來源:DroolsUtils.java

示例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();  
}
 
開發者ID:lansheng228,項目名稱:kie-dynamic-rule,代碼行數:12,代碼來源:DroolsUtils.java

示例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());
}
 
開發者ID:anurag-saran,項目名稱:sla-mgmt-brms,代碼行數:16,代碼來源:DecisionTableKieBaseProvider.java


注:本文中的org.kie.api.KieServices.newKieBuilder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。