@Test public void testGetProcessConfig() throws IOException { ProcessConfigModule processConfigModule = deploymentDescriptorServiceCDI.getProcessConfig(path + RUNTIME_STRATEGY_SINGLETON); assertEquals(RuntimeStrategy.SINGLETON, processConfigModule.getRuntimeStrategy()); assertEquals("myKie", processConfigModule.getKBase()); assertEquals("kiesession", processConfigModule.getKSession()); assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, deploymentDescriptorServiceCDI.getProcessConfig(path + RUNTIME_STRATEGY_PER_PROCESS_INSTANCE).getRuntimeStrategy()); assertEquals(RuntimeStrategy.PER_CASE, deploymentDescriptorServiceCDI.getProcessConfig(path + RUNTIME_STRATEGY_PER_CASE).getRuntimeStrategy()); assertEquals(RuntimeStrategy.PER_REQUEST, deploymentDescriptorServiceCDI.getProcessConfig(path + RUNTIME_STRATEGY_PER_REQUEST).getRuntimeStrategy()); }
@Override public ProcessConfigModule getProcessConfig(String path) throws IOException { ProcessConfigModule processConfig = new ProcessConfigModule(); KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); try (InputStream in = IOUtils.toInputStream(guvnorM2Repository.getKieDeploymentDescriptorText(path), StandardCharsets.UTF_8)) { RuntimeStrategy runtimeStrategy = DeploymentDescriptorIO.fromXml(in).getRuntimeStrategy(); switch (runtimeStrategy) { case SINGLETON: processConfig.setRuntimeStrategy(SINGLETON); break; case PER_CASE: processConfig.setRuntimeStrategy(PER_CASE); break; case PER_PROCESS_INSTANCE: processConfig.setRuntimeStrategy(PER_PROCESS_INSTANCE); break; case PER_REQUEST: processConfig.setRuntimeStrategy(PER_REQUEST); break; } } Map<String, KBaseModel> kBaseModelHashMap = kModuleContentHandler.toModel(guvnorM2Repository.getKModuleText(path)).getKBases(); KBaseModel defaultKBaseModel = null; Optional<KBaseModel> optionalKBaseModel = kBaseModelHashMap.values().stream().filter(KBaseModel::isDefault).findFirst(); if (optionalKBaseModel.isPresent()) { defaultKBaseModel = optionalKBaseModel.get(); } if (defaultKBaseModel != null) { processConfig.setKBase(defaultKBaseModel.getName()); Optional<KSessionModel> optionalKSessionModel = defaultKBaseModel.getKSessions().stream().filter(KSessionModel::isDefault).findFirst(); KSessionModel defaultKSessionModel = null; if (optionalKSessionModel.isPresent()) { defaultKSessionModel = optionalKSessionModel.get(); processConfig.setKSession(defaultKSessionModel.getName()); } } return processConfig; }
DeploymentDescriptorServiceCDI implements DeploymentDescriptorService { @Override public ProcessConfigModule getProcessConfig(String path) throws IOException { ProcessConfigModule processConfig = new ProcessConfigModule(); KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); try (InputStream in = IOUtils.toInputStream(guvnorM2Repository.getKieDeploymentDescriptorText(path), StandardCharsets.UTF_8)) { RuntimeStrategy runtimeStrategy = DeploymentDescriptorIO.fromXml(in).getRuntimeStrategy(); switch (runtimeStrategy) { case SINGLETON: processConfig.setRuntimeStrategy(SINGLETON); break; case PER_CASE: processConfig.setRuntimeStrategy(PER_CASE); break; case PER_PROCESS_INSTANCE: processConfig.setRuntimeStrategy(PER_PROCESS_INSTANCE); break; case PER_REQUEST: processConfig.setRuntimeStrategy(PER_REQUEST); break; } } Map<String, KBaseModel> kBaseModelHashMap = kModuleContentHandler.toModel(guvnorM2Repository.getKModuleText(path)).getKBases(); KBaseModel defaultKBaseModel = null; Optional<KBaseModel> optionalKBaseModel = kBaseModelHashMap.values().stream().filter(KBaseModel::isDefault).findFirst(); if (optionalKBaseModel.isPresent()) { defaultKBaseModel = optionalKBaseModel.get(); } if (defaultKBaseModel != null) { processConfig.setKBase(defaultKBaseModel.getName()); Optional<KSessionModel> optionalKSessionModel = defaultKBaseModel.getKSessions().stream().filter(KSessionModel::isDefault).findFirst(); KSessionModel defaultKSessionModel = null; if (optionalKSessionModel.isPresent()) { defaultKSessionModel = optionalKSessionModel.get(); processConfig.setKSession(defaultKSessionModel.getName()); } } return processConfig; } }
DeploymentDescriptorServiceCDI implements DeploymentDescriptorService { @Override public ProcessConfigModule getProcessConfig(String path) throws IOException { ProcessConfigModule processConfig = new ProcessConfigModule(); KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); try (InputStream in = IOUtils.toInputStream(guvnorM2Repository.getKieDeploymentDescriptorText(path), StandardCharsets.UTF_8)) { RuntimeStrategy runtimeStrategy = DeploymentDescriptorIO.fromXml(in).getRuntimeStrategy(); switch (runtimeStrategy) { case SINGLETON: processConfig.setRuntimeStrategy(SINGLETON); break; case PER_CASE: processConfig.setRuntimeStrategy(PER_CASE); break; case PER_PROCESS_INSTANCE: processConfig.setRuntimeStrategy(PER_PROCESS_INSTANCE); break; case PER_REQUEST: processConfig.setRuntimeStrategy(PER_REQUEST); break; } } Map<String, KBaseModel> kBaseModelHashMap = kModuleContentHandler.toModel(guvnorM2Repository.getKModuleText(path)).getKBases(); KBaseModel defaultKBaseModel = null; Optional<KBaseModel> optionalKBaseModel = kBaseModelHashMap.values().stream().filter(KBaseModel::isDefault).findFirst(); if (optionalKBaseModel.isPresent()) { defaultKBaseModel = optionalKBaseModel.get(); } if (defaultKBaseModel != null) { processConfig.setKBase(defaultKBaseModel.getName()); Optional<KSessionModel> optionalKSessionModel = defaultKBaseModel.getKSessions().stream().filter(KSessionModel::isDefault).findFirst(); KSessionModel defaultKSessionModel = null; if (optionalKSessionModel.isPresent()) { defaultKSessionModel = optionalKSessionModel.get(); processConfig.setKSession(defaultKSessionModel.getName()); } } return processConfig; } @Inject  DeploymentDescriptorServiceCDI(GuvnorM2Repository guvnorM2Repository); }
DeploymentDescriptorServiceCDI implements DeploymentDescriptorService { @Override public ProcessConfigModule getProcessConfig(String path) throws IOException { ProcessConfigModule processConfig = new ProcessConfigModule(); KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); try (InputStream in = IOUtils.toInputStream(guvnorM2Repository.getKieDeploymentDescriptorText(path), StandardCharsets.UTF_8)) { RuntimeStrategy runtimeStrategy = DeploymentDescriptorIO.fromXml(in).getRuntimeStrategy(); switch (runtimeStrategy) { case SINGLETON: processConfig.setRuntimeStrategy(SINGLETON); break; case PER_CASE: processConfig.setRuntimeStrategy(PER_CASE); break; case PER_PROCESS_INSTANCE: processConfig.setRuntimeStrategy(PER_PROCESS_INSTANCE); break; case PER_REQUEST: processConfig.setRuntimeStrategy(PER_REQUEST); break; } } Map<String, KBaseModel> kBaseModelHashMap = kModuleContentHandler.toModel(guvnorM2Repository.getKModuleText(path)).getKBases(); KBaseModel defaultKBaseModel = null; Optional<KBaseModel> optionalKBaseModel = kBaseModelHashMap.values().stream().filter(KBaseModel::isDefault).findFirst(); if (optionalKBaseModel.isPresent()) { defaultKBaseModel = optionalKBaseModel.get(); } if (defaultKBaseModel != null) { processConfig.setKBase(defaultKBaseModel.getName()); Optional<KSessionModel> optionalKSessionModel = defaultKBaseModel.getKSessions().stream().filter(KSessionModel::isDefault).findFirst(); KSessionModel defaultKSessionModel = null; if (optionalKSessionModel.isPresent()) { defaultKSessionModel = optionalKSessionModel.get(); processConfig.setKSession(defaultKSessionModel.getName()); } } return processConfig; } @Inject  DeploymentDescriptorServiceCDI(GuvnorM2Repository guvnorM2Repository); @Override ProcessConfigModule getProcessConfig(String path); }
DeploymentDescriptorServiceCDI implements DeploymentDescriptorService { @Override public ProcessConfigModule getProcessConfig(String path) throws IOException { ProcessConfigModule processConfig = new ProcessConfigModule(); KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); try (InputStream in = IOUtils.toInputStream(guvnorM2Repository.getKieDeploymentDescriptorText(path), StandardCharsets.UTF_8)) { RuntimeStrategy runtimeStrategy = DeploymentDescriptorIO.fromXml(in).getRuntimeStrategy(); switch (runtimeStrategy) { case SINGLETON: processConfig.setRuntimeStrategy(SINGLETON); break; case PER_CASE: processConfig.setRuntimeStrategy(PER_CASE); break; case PER_PROCESS_INSTANCE: processConfig.setRuntimeStrategy(PER_PROCESS_INSTANCE); break; case PER_REQUEST: processConfig.setRuntimeStrategy(PER_REQUEST); break; } } Map<String, KBaseModel> kBaseModelHashMap = kModuleContentHandler.toModel(guvnorM2Repository.getKModuleText(path)).getKBases(); KBaseModel defaultKBaseModel = null; Optional<KBaseModel> optionalKBaseModel = kBaseModelHashMap.values().stream().filter(KBaseModel::isDefault).findFirst(); if (optionalKBaseModel.isPresent()) { defaultKBaseModel = optionalKBaseModel.get(); } if (defaultKBaseModel != null) { processConfig.setKBase(defaultKBaseModel.getName()); Optional<KSessionModel> optionalKSessionModel = defaultKBaseModel.getKSessions().stream().filter(KSessionModel::isDefault).findFirst(); KSessionModel defaultKSessionModel = null; if (optionalKSessionModel.isPresent()) { defaultKSessionModel = optionalKSessionModel.get(); processConfig.setKSession(defaultKSessionModel.getName()); } } return processConfig; } @Inject  DeploymentDescriptorServiceCDI(GuvnorM2Repository guvnorM2Repository); @Override ProcessConfigModule getProcessConfig(String path);  }