use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class CommonTestMethodBase method deployJar.
public static KieModule deployJar(KieServices ks, byte[] jar) {
// Deploy jar into the repository
Resource jarRes = ks.getResources().newByteArrayResource(jar);
KieModule km = ks.getRepository().addKieModule(jarRes);
return km;
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class BuildtimeUtil method generateKJarFromKieBuilder.
public static void generateKJarFromKieBuilder(final KieBuilder kieBuilder, final boolean useCanonicalModel) throws IOException {
final ReleaseId releaseId = kieBuilder.getKieModule().getReleaseId();
final InternalKieModule kieModule = (InternalKieModule) kieBuilder.getKieModule();
final File kjarFile = bytesToTempFile(releaseId, kieModule.getBytes(), ".jar");
final KieModule zipKieModule;
if (useCanonicalModel) {
zipKieModule = new CanonicalKieModule(releaseId, kieModule.getKieModuleModel(), kjarFile);
} else {
zipKieModule = new ZipKieModule(releaseId, kieModule.getKieModuleModel(), kjarFile);
}
KieServices.get().getRepository().addKieModule(zipKieModule);
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class DefaultKieSessionFromByteArrayExampleTest method go.
public void go(PrintStream out) {
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieModule kModule = kr.addKieModule(ks.getResources().newByteArrayResource(getKjarAsByteArray(getFile("default-kiesession"))));
KieContainer kContainer = ks.newKieContainer(kModule.getReleaseId());
KieSession kSession = kContainer.newKieSession();
kSession.setGlobal("out", out);
Object msg1 = createMessage(kContainer, "Dave", "Hello, HAL. Do you read me, HAL?");
kSession.insert(msg1);
kSession.fireAllRules();
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class NamedKieSessionFromFileExample method go.
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();
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class KieScannerMemoryTest method testScannerMemoryFootprint.
@Test
public void testScannerMemoryFootprint() throws IOException {
final KieServices kieServices = KieServices.Factory.get();
final KieMavenRepository repository = KieMavenRepository.getKieMavenRepository();
final KieModule kieModule = KieBaseUtil.getKieModuleAndBuildInstallModuleFromDrl(TestConstants.PACKAGE_FUNCTIONAL, KieBaseTestConfiguration.CLOUD_IDENTITY, "rule R when then end");
final ReleaseId releaseId = kieModule.getReleaseId();
repository.installArtifact(releaseId, (InternalKieModule) kieModule, MavenUtil.createPomXml(fileManager, releaseId));
final KieContainer kieContainer = kieServices.newKieContainer(releaseId);
final KieScanner kieScanner = kieServices.newKieScanner(kieContainer);
kieScanner.start(20);
try {
measureMemoryFootprint(1000, 100, 6, 30);
} finally {
kieScanner.stop();
}
}
Aggregations