private InternalKieModule createKieJar(KieServices ks, KieFactory kf, GAV gav, String... rules)
      throws IOException {
    KieFileSystem kfs = kf.newKieFileSystem();
    for (String rule : rules) {
      String file = "org/test/" + rule + ".drl";
      kfs.write("src/main/resources/KBase1/" + file, createDRL(rule));
    }

    KieModuleModel kproj = kf.newKieModuleModel();

    KieBaseModel kieBaseModel1 =
        kproj
            .newKieBaseModel("KBase1")
            .setEqualsBehavior(AssertBehaviorOption.EQUALITY)
            .setEventProcessingMode(EventProcessingOption.STREAM);

    KieSessionModel ksession1 =
        kieBaseModel1
            .newKieSessionModel("KSession1")
            .setType(KieSessionType.STATEFUL)
            .setClockType(ClockTypeOption.get("realtime"));

    kfs.writeKModuleXML(kproj.toXML());
    kfs.writePomXML(getPom(gav));

    KieBuilder kieBuilder = ks.newKieBuilder(kfs);
    assertTrue(kieBuilder.build().getInsertedMessages().isEmpty());
    return (InternalKieModule) kieBuilder.getKieModule();
  }
  private InternalKieModule createKieJarWithClass(
      KieServices ks, KieFactory kf, GAV gav, int value, int factor) throws IOException {
    KieFileSystem kieFileSystem = kf.newKieFileSystem();

    KieModuleModel kproj = kf.newKieModuleModel();

    KieBaseModel kieBaseModel1 =
        kproj
            .newKieBaseModel("KBase1")
            .setEqualsBehavior(AssertBehaviorOption.EQUALITY)
            .setEventProcessingMode(EventProcessingOption.STREAM);

    KieSessionModel ksession1 =
        kieBaseModel1
            .newKieSessionModel("KSession1")
            .setType(KieSessionType.STATEFUL)
            .setClockType(ClockTypeOption.get("realtime"));

    kieFileSystem
        .writeKModuleXML(kproj.toXML())
        .writePomXML(getPom(gav))
        .write(
            "src/main/resources/" + kieBaseModel1.getName() + "/rule1.drl",
            createDRLForJavaSource(value))
        .write("src/main/java/org/kie/test/Bean.java", createJavaSource(factor));

    KieBuilder kieBuilder = ks.newKieBuilder(kieFileSystem);
    assertTrue(kieBuilder.build().getInsertedMessages().isEmpty());
    return (InternalKieModule) kieBuilder.getKieModule();
  }
예제 #3
0
 public void populateClasses(KieProject kproject, List<String> classes) {
   for (KieBaseModel kieBaseModel : kproject.getKieBaseModels().values()) {
     classes.add(kieBaseModel.getName() + "Producer.java");
     classes.add(kieBaseModel.getName() + ".java");
     for (KieSessionModel kieSessionModel : kieBaseModel.getKieSessionModels().values()) {
       classes.add(kieSessionModel.getName() + "Producer.java");
       classes.add(kieSessionModel.getName() + ".java");
     }
   }
 }