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


Java KieServices.newKieFileSystem方法代碼示例

本文整理匯總了Java中org.kie.api.KieServices.newKieFileSystem方法的典型用法代碼示例。如果您正苦於以下問題:Java KieServices.newKieFileSystem方法的具體用法?Java KieServices.newKieFileSystem怎麽用?Java KieServices.newKieFileSystem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kie.api.KieServices的用法示例。


在下文中一共展示了KieServices.newKieFileSystem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: createKJar

import org.kie.api.KieServices; //導入方法依賴的package包/類
public static byte[] createKJar(ReleaseId releaseId, List<String> drls) {
    KieServices kieServices = KieServices.Factory.get();
    KieFileSystem kfs = kieServices.newKieFileSystem();
    kfs.generateAndWritePomXML(releaseId);
    drls.forEach(drl -> kfs.write("src/main/resources/" + drl.hashCode() + ".drl", drl));
    KieBuilder kb = kieServices.newKieBuilder(kfs).buildAll();
    if (kb.getResults().hasMessages(Message.Level.ERROR)) {
        for (Message result : kb.getResults().getMessages()) {
            System.out.println(result.getText());
        }
        return null;
    }
    InternalKieModule kieModule = (InternalKieModule) kieServices.getRepository().getKieModule(releaseId);
    byte[] jar = kieModule.getBytes();
    return jar;
}
 
開發者ID:barrykalok,項目名稱:spring-boot-drools-example,代碼行數:17,代碼來源:RuleEngineUtil.java

示例3: 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

示例4: createKieFileSystemWithKProject

import org.kie.api.KieServices; //導入方法依賴的package包/類
/** 
 * 創建默認的kbase和stateful的kiesession 
 * 
 * @param ks 
 * @param isdefault 
 * @return 
 */  
public static KieFileSystem createKieFileSystemWithKProject(KieServices ks, boolean isdefault) {  
    KieModuleModel kproj = ks.newKieModuleModel();  
    KieBaseModel kieBaseModel1 = kproj.newKieBaseModel("KBase").setDefault(isdefault)  
            .setEqualsBehavior(EqualityBehaviorOption.EQUALITY).setEventProcessingMode(EventProcessingOption.STREAM);  
    // Configure the KieSession.  
    kieBaseModel1.newKieSessionModel("KSession").setDefault(isdefault)  
            .setType(KieSessionModel.KieSessionType.STATEFUL);  
    KieFileSystem kfs = ks.newKieFileSystem();  
    kfs.writeKModuleXML(kproj.toXML());  
    return kfs;  
}
 
開發者ID:lansheng228,項目名稱:kie-dynamic-rule,代碼行數:19,代碼來源:DroolsUtils.java

示例5: buildRelease

import org.kie.api.KieServices; //導入方法依賴的package包/類
private static void buildRelease(ReleaseId releaseId, Resource pomResource, Resource kmodule, String... resources) {
    if (releases.contains(releaseId)) {
        ks.getRepository().removeKieModule(releaseId);
    }
    KieServices kieServices = KieServices.Factory.get();

    KieFileSystem kfs = kieServices.newKieFileSystem();

    kfs.write("pom.xml", pomResource);

    kfs.write("src/main/resources/META-INF/kmodule.xml", kmodule);

    for (String res : resources) {
        Resource resource = new ClassPathResource(res);
        kfs.write("src/main/resources/" + res, resource);
    }

    hasErrors(kieServices.newKieBuilder(kfs).buildAll().getResults());

    releases.add(releaseId);
}
 
開發者ID:redhat-italy,項目名稱:hacep,代碼行數:22,代碼來源:KieAPITestUtils.java

示例6: 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

示例7: getKieSession

import org.kie.api.KieServices; //導入方法依賴的package包/類
/** create empty knowledge base */
private KieSession getKieSession() {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();
    KieResources kieResources = ks.getResources();

    kfs.write(kieResources.newClassPathResource("getOlder.drl", getClass()).setResourceType(ResourceType.DRL));

    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();

    List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
    if (!errors.isEmpty()) {
        fail("" + errors);
    }

    return ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:18,代碼來源:JsonQueryTest.java

示例8: registerKnowledgeRuntime

import org.kie.api.KieServices; //導入方法依賴的package包/類
protected KieSession registerKnowledgeRuntime(String identifier, String rule) {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();
    KieResources kieResources = ks.getResources();

    if (rule != null && rule.length() > 0) {
        kfs.write("src/main/resources/rule.drl", rule);
    }

    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();

    List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
    if (!errors.isEmpty()) {
        fail("" + errors);
    }

    KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();

    try {
        jndiContext.bind(identifier, ksession);
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }

    return ksession;
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:27,代碼來源:KieCamelTestSupport.java

示例9: 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

示例10: getStatelessKieSessionFromResource

import org.kie.api.KieServices; //導入方法依賴的package包/類
private StatelessKieSession getStatelessKieSessionFromResource(Resource resource) {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();

    kfs.write(resource);

    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();

    List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
    if (!errors.isEmpty()) {
        fail("" + errors);
    }

    return ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newStatelessKieSession();
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:16,代碼來源:XStreamBatchExecutionTest.java

示例11: getKieSessionFromResource

import org.kie.api.KieServices; //導入方法依賴的package包/類
private KieSession getKieSessionFromResource(Resource resource) {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();

    kfs.write(resource);

    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();

    List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
    if (!errors.isEmpty()) {
        fail("" + errors);
    }

    return ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:16,代碼來源:XStreamBatchExecutionTest.java

示例12: registerKnowledgeRuntime

import org.kie.api.KieServices; //導入方法依賴的package包/類
@Override
protected KieSession registerKnowledgeRuntime(String identifier, String rule) {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();
    KieResources kieResources = ks.getResources();

    Options xjcOpts = new Options();
    xjcOpts.setSchemaLanguage(Language.XMLSCHEMA);

    JaxbConfiguration jaxbConfiguration = KnowledgeBuilderFactory.newJaxbConfiguration(xjcOpts, "xsd");

    kfs.write(kieResources.newClassPathResource("person.xsd", getClass()).setResourceType(ResourceType.XSD).setConfiguration(jaxbConfiguration));

    if (rule != null && rule.length() > 0) {
        kfs.write("src/main/resources/rule.drl", rule);
    }

    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();

    List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
    if (!errors.isEmpty()) {
        fail("" + errors);
    }

    KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
    classLoader = ((KnowledgeBaseImpl)ksession.getKieBase()).getRootClassLoader();

    try {
        jndiContext.bind(identifier, ksession);
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }

    return ksession;
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:36,代碼來源:CamelEndpointWithJaxbXSDModelTest.java

示例13: registerKnowledgeRuntime

import org.kie.api.KieServices; //導入方法依賴的package包/類
@Override
protected KieSession registerKnowledgeRuntime(String identifier, String rule) {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();
    KieResources kieResources = ks.getResources();

    Options xjcOpts = new Options();
    xjcOpts.setSchemaLanguage(Language.XMLSCHEMA);

    JaxbConfiguration jaxbConfiguration = KnowledgeBuilderFactory.newJaxbConfiguration(xjcOpts, "xsd");

    kfs.write(kieResources.newClassPathResource("person.xsd", getClass()).setResourceType(ResourceType.XSD).setConfiguration(jaxbConfiguration));

    if (rule != null && rule.length() > 0) {
        kfs.write("src/main/resources/rule.drl", rule);
    }

    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();

    List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
    if (!errors.isEmpty()) {
        fail("" + errors);
    }

    KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();

    try {
        jndiContext.bind(identifier, ksession);
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }

    return ksession;
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:35,代碼來源:CamelEndpointWithJaxWrapperCollectionTest.java

示例14: getStatelessKieSessionFromResource

import org.kie.api.KieServices; //導入方法依賴的package包/類
private StatelessKieSession getStatelessKieSessionFromResource(Resource resource) throws Exception {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();

    kfs.write(resource);

    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();

    List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
    if (!errors.isEmpty()) {
        fail("" + errors);
    }

    return ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newStatelessKieSession();
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:16,代碼來源:BatchTest.java

示例15: getKieSessionFromResource

import org.kie.api.KieServices; //導入方法依賴的package包/類
private KieSession getKieSessionFromResource(Resource resource) throws Exception {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();

    kfs.write(resource);

    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();

    List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
    if (!errors.isEmpty()) {
        fail("" + errors);
    }

    return ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:16,代碼來源:BatchTest.java


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