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


Java KieModule类代码示例

本文整理汇总了Java中org.kie.api.builder.KieModule的典型用法代码示例。如果您正苦于以下问题:Java KieModule类的具体用法?Java KieModule怎么用?Java KieModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: refreshContainer

import org.kie.api.builder.KieModule; //导入依赖的package包/类
public void refreshContainer(String containerName){

        logger.info("refreshing container {}", containerName);

        ReleaseId releaseId = new ReleaseIdImpl("org.demo.rule", containerName, "1.0.0-" + UUID.randomUUID().toString().replaceAll("-", ""));

        // retrieve rules from db
        List<String> rules = ruleBucket.findAll().stream().map((r -> r.getContent())).collect(Collectors.toList());
        logger.info("total {} rules for [{}]", rules.size(), ruleBucket);
        Resource resource = kieServices.getResources().newByteArrayResource(RuleEngineUtil.createKJar(releaseId, rules));

        KieModule module = kieServices.getRepository().addKieModule(resource);
        KieContainer kieContainer = kieServices.newKieContainer(module.getReleaseId());

        // create container is heavy, we only create once and cache it
        containerMap.put(containerName, kieContainer);

        // remove the repo immediately
        kieServices.getRepository().removeKieModule(module.getReleaseId());
    }
 
开发者ID:barrykalok,项目名称:spring-boot-drools-example,代码行数:21,代码来源:RuleService.java

示例2: doTest

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Test
public void doTest() throws IOException {
	KieServices ks = KieServices.Factory.get();
	KieRepository kr = ks.getRepository();
	UrlResource urlResource = (UrlResource) ks.getResources().newUrlResource(URL);
	urlResource.setUsername(USER);
	urlResource.setPassword(PASSWORD);
	urlResource.setBasicAuthentication("enabled");
	InputStream is = urlResource.getInputStream();
	KieModule kModule = kr.addKieModule(ks.getResources().newInputStreamResource(is));
	KieContainer kc = ks.newKieContainer(kModule.getReleaseId());
	// This fact was created using Data Modeller in business central
//	Product p = new Product();
//	p.setName("Table");
//	p.setPrice(500f);
	KieSession kSession = kc.newKieSession();
//	kSession.insert(p);
	kSession.fireAllRules();
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:20,代码来源:MavenArtifactTest.java

示例3: kieContainer

import org.kie.api.builder.KieModule; //导入依赖的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

示例4: getKieBase

import org.kie.api.builder.KieModule; //导入依赖的package包/类
private KieBase getKieBase(String url, String usr, String password) throws IOException {
	KieServices ks = KieServices.Factory.get();
	KieRepository kr = ks.getRepository();
	UrlResource urlResource = (UrlResource) ks.getResources().newUrlResource(URL);
	urlResource.setUsername(USER);
	urlResource.setPassword(PASSWORD);
	urlResource.setBasicAuthentication("enabled");
	InputStream is = urlResource.getInputStream();
	KieModule kModule = kr.addKieModule(ks.getResources().newInputStreamResource(is));
	KieContainer kc = ks.newKieContainer(kModule.getReleaseId());
	return kc.getKieBase();		
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:13,代码来源:HumanTaskTest.java

示例5: doTest

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Test
public void doTest() throws IOException {
	KieServices ks = KieServices.Factory.get();
	KieRepository kr = ks.getRepository();
	UrlResource urlResource = (UrlResource) ks.getResources().newUrlResource(URL);
	urlResource.setUsername(USER);
	urlResource.setPassword(PASSWORD);
	urlResource.setBasicAuthentication("enabled");
	InputStream is = urlResource.getInputStream();
	KieModule kModule = kr.addKieModule(ks.getResources().newInputStreamResource(is));
	KieContainer kc = ks.newKieContainer(kModule.getReleaseId());
	KieSession kSession = kc.newKieSession();
	kSession.startProcess("project1.hello");
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:15,代码来源:UrlResourceTest.java

示例6: getKieContainer

import org.kie.api.builder.KieModule; //导入依赖的package包/类
/**
 * Creating a KieBase from the workflow GAV specified in the config.
 *
 * @return KieBase for package SRAMPPackage
 *
 * @throws SrampClientException
 * @throws SrampAtomException
 */
public KieContainer getKieContainer(ReleaseId releaseId) throws SrampClientException, SrampAtomException {
	KieServices ks = KieServices.Factory.get();
   	KieRepository repo = ks.getRepository();
   	SrampAtomApiClient client = SrampAtomApiClientFactory.createAtomApiClient();

	Governance governance = new Governance();
       String workflowGroupId = releaseId.getGroupId();
       String workflowArtifactId = releaseId.getArtifactId();

       String workflowVersion = releaseId.getVersion();
       if (StringUtils.isBlank(workflowVersion)) {
           throw new RuntimeException(Messages.i18n.format("maven.version.not.found", workflowGroupId, workflowArtifactId, workflowVersion)); //$NON-NLS-1$
       }
       QueryResultSet results = null;
       ArtifactSummary artifactSummary = null;

       results = client.buildQuery(SRAMP_KIE_JAR_QUERY).parameter(workflowGroupId).parameter(workflowArtifactId).parameter(workflowVersion).count(1)
               .query();

	if (results.size() > 0) {
           artifactSummary = results.get(0);
		InputStream is = client.getArtifactContent(artifactSummary);
		KieModule kModule = repo.addKieModule(ks.getResources().newInputStreamResource(is));
		logger.info(Messages.i18n.format("KieSrampUtil.CreatingKieContainer", artifactSummary.getName())); //$NON-NLS-1$
		KieContainer kContainer = ks.newKieContainer(kModule.getReleaseId());
		//Creating the KieBase for the SRAMPPackage
    	logger.info(Messages.i18n.format("KieSrampUtil.FindKieBase", governance.getGovernanceWorkflowPackage())); //$NON-NLS-1$
		return kContainer;
	} else {
		return null;
	}

}
 
开发者ID:Governance,项目名称:dtgov,代码行数:42,代码来源:KieSrampUtil.java

示例7: DefaultKieCompilationResponse

import org.kie.api.builder.KieModule; //导入依赖的package包/类
public DefaultKieCompilationResponse(Boolean successful,
                                     KieModuleMetaInfo kieModuleMetaInfo,
                                     KieModule kieModule,
                                     List<String> mavenOutput,
                                     List<URI> projectDependencies) {

    defaultResponse = new DefaultCompilationResponse(successful,
                                                     mavenOutput);
    this.kieModuleMetaInfo = Optional.ofNullable(kieModuleMetaInfo);
    this.kieModule = Optional.ofNullable(kieModule);
    this.projectDependencies = Optional.ofNullable(projectDependencies);
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:13,代码来源:DefaultKieCompilationResponse.java

示例8: getKieFromFile

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Test @Ignore
  public void getKieFromFile() {
  	KieServices ks = KieServices.Factory.get();
  	
  	KieRepository repo = ks.getRepository();
  	
  	InputStream is = this.getClass().getResourceAsStream("/dtgov-workflows.jar"); //$NON-NLS-1$
  	
  	KieModule kModule = repo.addKieModule(ks.getResources().newInputStreamResource(is));
  	
  	@SuppressWarnings("unused")
ReleaseId releaseId = kModule.getReleaseId();
  	KieContainer kContainer = ks.newKieContainer(kModule.getReleaseId());
  	
  	Assert.assertNotNull(kContainer);

KieBase kieBase = kContainer.getKieBase("SRAMPPackage"); //$NON-NLS-1$
      Assert.assertNotNull(kieBase);

      System.out.println("KieBase=" + kieBase); //$NON-NLS-1$
  }
 
开发者ID:Governance,项目名称:dtgov,代码行数:22,代码来源:KieTest.java

示例9: getKieModule

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Override
public KieModule getKieModule( ) {
    return builder.getKieModule();
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:5,代码来源:BuildInfoImpl.java

示例10: getKieModuleIgnoringErrors

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Override
public KieModule getKieModuleIgnoringErrors( ) {
    return builder.getKieModuleIgnoringErrors();
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:5,代码来源:BuildInfoImpl.java

示例11: getKieModule

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Override
public Optional<KieModule> getKieModule() {
    return kieModule;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:5,代码来源:DefaultKieCompilationResponse.java

示例12: handleKieMavenPlugin

import org.kie.api.builder.KieModule; //导入依赖的package包/类
private KieCompilationResponse handleKieMavenPlugin(CompilationRequest req,
                                                    CompilationResponse res) {

    KieTuple kieModuleMetaInfoTuple = readKieModuleMetaInfo(req);
    KieTuple kieModuleTuple = readKieModule(req);
    if (kieModuleMetaInfoTuple.getOptionalObject().isPresent() && kieModuleTuple.getOptionalObject().isPresent()) {

        AFClassLoaderProvider provider = new ClassLoaderProviderImpl();
        Optional<List<URI>> optionalDeps = provider.getURISFromAllDependencies(req.getInfo().getPrjPath().toAbsolutePath().toString());
        List<URI> uris = Collections.emptyList();
        if(optionalDeps.isPresent()){
            uris = optionalDeps.get();
        }
        if (req.getKieCliRequest().isLogRequested()) {
            return new DefaultKieCompilationResponse(Boolean.TRUE,
                                                     (KieModuleMetaInfo) kieModuleMetaInfoTuple.getOptionalObject().get(),
                                                     (KieModule) kieModuleTuple.getOptionalObject().get(),
                                                     res.getMavenOutput().get(),
                                                     uris);
        } else {
            return new DefaultKieCompilationResponse(Boolean.TRUE,
                                                     (KieModuleMetaInfo) kieModuleMetaInfoTuple.getOptionalObject().get(),
                                                     (KieModule) kieModuleTuple.getOptionalObject().get(),
                                                     uris);
        }
    } else {
        StringBuilder sb = new StringBuilder();
        if (kieModuleMetaInfoTuple.getErrorMsg().isPresent()) {
            sb.append(" Error in the kieModuleMetaInfo from the kieMap:").append(kieModuleMetaInfoTuple.getErrorMsg().get());
        }
        if (kieModuleTuple.getErrorMsg().isPresent()) {
            sb.append(" Error in the kieModule:").append(kieModuleTuple.getErrorMsg().get());
        }
        if (req.getKieCliRequest().isLogRequested()) {
            return new DefaultKieCompilationResponse(Boolean.FALSE,
                                                     sb.toString(),
                                                     res.getMavenOutput().get());
        } else {
            return new DefaultKieCompilationResponse(Boolean.FALSE,
                                                     sb.toString());
        }
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:44,代码来源:KieAfterDecorator.java

示例13: compileAndLoadKieJarMetadataAllResourcesPackagedJar

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Test
public void compileAndLoadKieJarMetadataAllResourcesPackagedJar() throws Exception {
    /**
     * If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
     * */
    String alternateSettingsAbsPath = new File("src/test/settings.xml").getAbsolutePath();
    //compile and install
    Path tmpRoot = Files.createTempDirectory("repo");
    //NIO creation and copy content
    Path temp = Files.createDirectories(Paths.get(tmpRoot.toString(),
                                                  "dummy"));
    TestUtil.copyTree(Paths.get("target/test-classes/kjar-2-all-resources"),
                      temp);
    //end NIO

    AFCompiler compiler = KieMavenCompilerFactory.getCompiler(
            KieDecorator.KIE_AND_LOG_AFTER);

    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(temp);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(),
                                                           info,
                                                           new String[]{MavenCLIArgs.INSTALL, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath},
                                                           new HashMap<>(),
                                                           Boolean.TRUE);
    KieCompilationResponse res = (KieCompilationResponse) compiler.compileSync(req);

    if (res.getMavenOutput().isPresent() && !res.isSuccessful()) {
        TestUtil.writeMavenOutputIntoTargetFolder(res.getMavenOutput().get(),
                                                  "KieMetadataTest.compileAndLoadKieJarMetadataAllResourcesPackagedJar");
    }

    if (res.getErrorMessage().isPresent()) {
        logger.info("Error:" + res.getErrorMessage().get());
    }

    Assert.assertTrue(res.isSuccessful());

    Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
    Assert.assertTrue(metaDataOptional.isPresent());
    KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
    Assert.assertNotNull(kieModuleMetaInfo);

    Map<String, Set<String>> rulesBP = kieModuleMetaInfo.getRulesByPackage();
    Assert.assertEquals(rulesBP.size(),
                        8);
    Map<String, TypeMetaInfo> typesMI = kieModuleMetaInfo.getTypeMetaInfos();
    Assert.assertEquals(typesMI.size(),
                        35);

    Optional<KieModule> kieModuleOptional = res.getKieModule();
    Assert.assertTrue(kieModuleOptional.isPresent());

    Assert.assertTrue(res.getProjectDependencies().isPresent());
    Assert.assertTrue(res.getProjectDependencies().get().size() == 5);
    KieModule kModule = kieModuleOptional.get();

    KieModuleMetaData kieModuleMetaData = new KieModuleMetaDataImpl((InternalKieModule) kModule,
                                                                    res.getProjectDependencies().get());
    Assert.assertNotNull(kieModuleMetaData);
    //comment if you want read the log file after the test run
    TestUtil.rm(tmpRoot.toFile());
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:63,代码来源:KieMetadataTest.java

示例14: compileAndloadKieJarSingleMetadata

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Test
public void compileAndloadKieJarSingleMetadata() {
    /**
     * If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
     * */
    String alternateSettingsAbsPath = new File("src/test/settings.xml").getAbsolutePath();
    try {
        Path tmpRoot = Files.createTempDirectory("repo");
        Path tmp = Files.createDirectories(Paths.get(tmpRoot.toString(),
                                                     "dummy"));
        TestUtil.copyTree(Paths.get("target/test-classes/kjar-2-single-resources"),
                          tmp);

        AFCompiler compiler = KieMavenCompilerFactory.getCompiler(
                KieDecorator.KIE_AND_LOG_AFTER);

        WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri()));

        CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(),
                                                               info,
                                                               new String[]{MavenCLIArgs.INSTALL, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath},
                                                               new HashMap<>(),
                                                               Boolean.TRUE);
        KieCompilationResponse res = (KieCompilationResponse) compiler.compileSync(req);

        if (res.getMavenOutput().isPresent() && !res.isSuccessful()) {
            TestUtil.writeMavenOutputIntoTargetFolder(res.getMavenOutput().get(),
                                                      "KieMetadataTest.compileAndloadKieJarSingleMetadata");
        }

        Assert.assertTrue(res.getMavenOutput().isPresent());
        if (res.getErrorMessage().isPresent()) {
            logger.info(res.getErrorMessage().get());
        }

        Assert.assertTrue(res.isSuccessful());

        Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
        Assert.assertTrue(metaDataOptional.isPresent());
        KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
        Assert.assertNotNull(kieModuleMetaInfo);

        Map<String, Set<String>> rulesBP = kieModuleMetaInfo.getRulesByPackage();
        Assert.assertEquals(rulesBP.size(),
                            1);

        Optional<KieModule> kieModuleOptional = res.getKieModule();
        Assert.assertTrue(kieModuleOptional.isPresent());

        Assert.assertTrue(res.getProjectDependencies().isPresent());
        Assert.assertTrue(res.getProjectDependencies().get().size() == 5);

        //comment if you want read the log file after the test run
        TestUtil.rm(tmpRoot.toFile());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:59,代码来源:KieMetadataTest.java

示例15: compileAndloadKieJarSingleMetadataWithPackagedJar

import org.kie.api.builder.KieModule; //导入依赖的package包/类
@Test
public void compileAndloadKieJarSingleMetadataWithPackagedJar() throws Exception {
    /**
     * If the test fail check if the Drools core classes used, KieModuleMetaInfo and TypeMetaInfo implements Serializable
     * */
    String alternateSettingsAbsPath = new File("src/test/settings.xml").getAbsolutePath();
    Path tmpRoot = Files.createTempDirectory("repo");
    Path tmp = Files.createDirectories(Paths.get(tmpRoot.toString(),
                                                 "dummy"));
    TestUtil.copyTree(Paths.get("target/test-classes/kjar-2-single-resources"),
                      tmp);

    AFCompiler compiler = KieMavenCompilerFactory.getCompiler(KieDecorator.KIE_AFTER);

    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get(tmp.toUri()));
    CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(),
                                                           info,
                                                           new String[]{MavenCLIArgs.INSTALL, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath},
                                                           new HashMap<>(),
                                                           Boolean.FALSE);
    KieCompilationResponse res = (KieCompilationResponse) compiler.compileSync(req);
    if (res.getMavenOutput().isPresent() && !res.isSuccessful()) {
        TestUtil.writeMavenOutputIntoTargetFolder(res.getMavenOutput().get(),
                                                  "KieMetadataTest.compileAndloadKieJarSingleMetadataWithPackagedJar");
    }
    if (res.getErrorMessage().isPresent()) {
        logger.info(res.getErrorMessage().get());
    }

    Assert.assertTrue(res.isSuccessful());

    Optional<KieModuleMetaInfo> metaDataOptional = res.getKieModuleMetaInfo();
    Assert.assertTrue(metaDataOptional.isPresent());
    KieModuleMetaInfo kieModuleMetaInfo = metaDataOptional.get();
    Assert.assertNotNull(kieModuleMetaInfo);

    Map<String, Set<String>> rulesBP = kieModuleMetaInfo.getRulesByPackage();
    Assert.assertEquals(rulesBP.size(),
                        1);

    Optional<KieModule> kieModuleOptional = res.getKieModule();
    Assert.assertTrue(kieModuleOptional.isPresent());
    KieModule kModule = kieModuleOptional.get();

    Assert.assertTrue(res.getProjectDependencies().isPresent());
    Assert.assertTrue(res.getProjectDependencies().get().size() == 5);

    KieModuleMetaData kieModuleMetaData = new KieModuleMetaDataImpl((InternalKieModule) kModule,
                                                                    res.getProjectDependencies().get());

    //KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(kModule); // broken
    Assert.assertNotNull(kieModuleMetaData);

    //comment if you want read the log file after the test run
    TestUtil.rm(tmpRoot.toFile());
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:57,代码来源:KieMetadataTest.java


注:本文中的org.kie.api.builder.KieModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。