/** * 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(); QueryResultSet results = client .buildQuery(SRAMP_KIE_JAR_QUERY) .parameter(governance.getGovernanceWorkflowGroup()) .parameter(governance.getGovernanceWorkflowName()) .parameter(governance.getGovernanceWorkflowVersion()) .count(1) .query(); if (results.size() > 0) { ArtifactSummary artifactSummery = results.get(0); InputStream is = client.getArtifactContent(artifactSummery); KieModule kModule = repo.addKieModule(ks.getResources().newInputStreamResource(is)); logger.info( Messages.i18n.format( "KieSrampUtil.CreatingKieContainer", artifactSummery)); // $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; } }
public void go(PrintStream out) { KieServices ks = KieServices.Factory.get(); KieRepository kr = ks.getRepository(); KieModule kModule = kr.addKieModule(ks.getResources().newFileSystemResource(getFile("named-kiesession"))); KieContainer kContainer = ks.newKieContainer(kModule.getReleaseId()); KieSession kSession = kContainer.newKieSession("ksession1"); kSession.setGlobal("out", out); Object msg1 = createMessage(kContainer, "Dave", "Hello, HAL. Do you read me, HAL?"); kSession.insert(msg1); kSession.fireAllRules(); }
public void discoverKieModules() { String[] configFiles = { KieModuleModelImpl.KMODULE_JAR_PATH, KieModuleModelImpl.KMODULE_SPRING_JAR_PATH }; for (String configFile : configFiles) { final Enumeration<URL> e; try { e = classLoader.getResources(configFile); } catch (IOException exc) { log.error("Unable to find and build index of " + configFile + "." + exc.getMessage()); return; } // Map of kmodule urls while (e.hasMoreElements()) { URL url = e.nextElement(); notifyKieModuleFound(url); try { InternalKieModule kModule = fetchKModule(url); if (kModule != null) { ReleaseId releaseId = kModule.getReleaseId(); kieModules.put(releaseId, kModule); log.debug("Discovered classpath module " + releaseId.toExternalForm()); kieRepository.addKieModule(kModule); } } catch (Exception exc) { log.error( "Unable to build index of kmodule.xml url=" + url.toExternalForm() + "\n" + exc.getMessage()); } } } }