use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class BuildFromKJarBenchmark method buildKnowledge.
@Benchmark
public KieBase buildKnowledge(final Blackhole eater) {
final KieModule zipKieModule = type.useRuleModel ? new CanonicalKieModule(releaseId, kieModuleModel, kjarFiles.getJarFile(), kjarFiles.getKnowledgeFiles()) : new ZipKieModule(releaseId, kieModuleModel, kjarFiles.getJarFile());
kieRepository.addKieModule(zipKieModule);
if (eater != null) {
eater.consume(zipKieModule);
}
return kieServices.newKieContainer(releaseId).getKieBase();
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class KieHelper method deployJarIntoRepository.
private static KieModule deployJarIntoRepository(KieServices ks, byte[] jar) {
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 JavaBeansEventRoleTest method testImportBean.
@Test
public void testImportBean() throws Exception {
String declaration = "package org.drools.compiler;\n" + "public class Bean {}";
String drl = "package some.other.package;\n" + "import org.drools.compiler.Bean;\n" + "declare Bean\n" + " @role(event)\n" + "end";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/java/org/drools/compiler/Bean.java", declaration).write("src/main/resources/bean1.drl", drl);
final KieBuilder kieBuilder = ks.newKieBuilder(kfs);
final KieModule kieModule = kieBuilder.buildAll().getKieModule();
final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(kieModule);
final String packageName = "org.drools.compiler";
final String className = "Bean";
final Class clazz = kieModuleMetaData.getClass(packageName, className);
final TypeMetaInfo typeMetaInfo = kieModuleMetaData.getTypeMetaInfo(clazz);
assertTrue(typeMetaInfo.isEvent());
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class JavaBeansEventRoleTest method testBeanAndDeclarativeTypeInSamePackage.
@Test
public void testBeanAndDeclarativeTypeInSamePackage() throws Exception {
String declaration = "package org.drools.compiler;\n" + "public class Bean {}";
String drl = "package org.drools.compiler;\n" + "declare Bean\n" + " @role(event)\n" + "end";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/java/org/drools/compiler/Bean.java", declaration).write("src/main/resources/bean1.drl", drl);
final KieBuilder kieBuilder = ks.newKieBuilder(kfs);
final KieModule kieModule = kieBuilder.buildAll().getKieModule();
final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(kieModule);
final String packageName = "org.drools.compiler";
final String className = "Bean";
final Class clazz = kieModuleMetaData.getClass(packageName, className);
final TypeMetaInfo typeMetaInfo = kieModuleMetaData.getTypeMetaInfo(clazz);
assertTrue(typeMetaInfo.isEvent());
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class AbstractKieCiTest 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;
}
Aggregations