当前位置: 首页>>代码示例>>Java>>正文


Java KieBuilder.buildAll方法代码示例

本文整理汇总了Java中org.kie.api.builder.KieBuilder.buildAll方法的典型用法代码示例。如果您正苦于以下问题:Java KieBuilder.buildAll方法的具体用法?Java KieBuilder.buildAll怎么用?Java KieBuilder.buildAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kie.api.builder.KieBuilder的用法示例。


在下文中一共展示了KieBuilder.buildAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initKie

import org.kie.api.builder.KieBuilder; //导入方法依赖的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.builder.KieBuilder; //导入方法依赖的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.builder.KieBuilder; //导入方法依赖的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: generateRelease

import org.kie.api.builder.KieBuilder; //导入方法依赖的package包/类
private ReleaseId generateRelease(Collection<Precondition> preconditionsToAdd, Collection<Precondition> preconditionsToRemove) throws EngineException {
    if (services == null) {
        throw new IllegalStateException("Engine not initialized.");
    }
    ReleaseId release = services.newReleaseId(RELEASE_GROUP_ID, RELEASE_ARTIFACT_ID, String.valueOf(versionNumber++));
    if (preconditionsToAdd != null) {
        addPreconditionsRules(preconditionsToAdd);
    }
    if (preconditionsToRemove != null) {
        deletePreconditionRules(preconditionsToRemove);
    }
    fileSystem.generateAndWritePomXML(release);
    KieBuilder builder = services.newKieBuilder(fileSystem);
    builder.buildAll();
    if (builder.getResults().hasMessages(org.kie.api.builder.Message.Level.ERROR)) {
        // TODO - Check if the error is due to wrong evaluation string specifications and launch a specific exception
        throw new EngineException("Engine errors:\n" + builder.getResults().toString());
    }
    return release;
}
 
开发者ID:Inter-Trust,项目名称:Policy_Interpreter,代码行数:21,代码来源:Engine.java

示例5: addRuleSet

import org.kie.api.builder.KieBuilder; //导入方法依赖的package包/类
public void addRuleSet(String ruleSetName, File ruleSetDirectory) throws RuleExecutorException {
	// Create the in-memory File System and add the resources files  to it
	KieFileSystem kieFileSystem = kieServices.newKieFileSystem();

	try {
		final RuleLoader ruleLoader = new RuleLoader(kieFileSystem);
		Files.walkFileTree(ruleSetDirectory.toPath(), ruleLoader);
		int rulesLoaded = ruleLoader.getRulesLoaded();
		if (rulesLoaded == 0) {
			logger.warn("No rules loaded. Rules directory: {}", ruleSetDirectory.getAbsolutePath());
		} else {
			logger.info("{} rules loaded.", ruleLoader.getRulesLoaded());
			totalRulesLoaded += rulesLoaded;
		}
	} catch (IOException e) {
		throw new RuleExecutorException("Failed to load rule set " + ruleSetName, e);
	}

	// Create the builder for the resources of the File System
	KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem);

	// Build the KieBases
	kieBuilder.buildAll();

	// Check for errors
	if (kieBuilder.getResults().hasMessages(Message.Level.ERROR)) {
		throw new RuleExecutorException(kieBuilder.getResults().toString());
	}

	// Get the Release ID (mvn style: groupId, artifactId,version)
	ReleaseId relId = kieBuilder.getKieModule().getReleaseId();

	// Create the Container, wrapping the KieModule with the given ReleaseId
	ruleSetContainers.put(ruleSetName, kieServices.newKieContainer(relId));
}
 
开发者ID:IHTSDO,项目名称:snomed-drools,代码行数:36,代码来源:RuleExecutor.java

示例6: kieContainer

import org.kie.api.builder.KieBuilder; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean(KieContainer.class)
public KieContainer kieContainer() throws IOException {
    final KieRepository kieRepository = getKieServices().getRepository();
    
    kieRepository.addKieModule(new KieModule() {
        public ReleaseId getReleaseId() {
            return kieRepository.getDefaultReleaseId();
        }
    });
    
    KieBuilder kieBuilder = getKieServices().newKieBuilder(kieFileSystem()); 
    kieBuilder.buildAll();
    
    return getKieServices().newKieContainer(kieRepository.getDefaultReleaseId());
}
 
开发者ID:jonashackt,项目名称:spring-boot-starter-drools,代码行数:17,代码来源:DroolsAutoConfiguration.java

示例7: DecisionTableKieBaseProvider

import org.kie.api.builder.KieBuilder; //导入方法依赖的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.builder.KieBuilder.buildAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。