use of org.kie.api.builder.KieRepository in project duangframework by tcrct.
the class KieSessionHolder method loadKieContainer.
private KieContainer loadKieContainer() throws IOException {
final KieServices ks = getKieServices();
final KieRepository kr = ks.getRepository();
final KieBuilder kb = ks.newKieBuilder(kieFileSystem());
kb.buildAll();
if (kb.getResults().hasMessages(Message.Level.ERROR)) {
throw new RuntimeException("Build Errors: " + kb.getResults().toString());
}
final KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
logger.warn("init kie container success");
return kContainer;
}
use of org.kie.api.builder.KieRepository in project jbpm by kiegroup.
the class JbpmBpmn2TestCase method createKnowledgeBaseFromResources.
protected KieBase createKnowledgeBaseFromResources(Resource... process) throws Exception {
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
if (process.length > 0) {
KieFileSystem kfs = ks.newKieFileSystem();
for (Resource p : process) {
kfs.write(p);
}
KieBuilder kb = ks.newKieBuilder(kfs);
// kieModule is automatically deployed to KieRepository
kb.buildAll();
if (kb.getResults().hasMessages(Level.ERROR)) {
throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
}
}
KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
return kContainer.getKieBase();
}
use of org.kie.api.builder.KieRepository in project jbpm by kiegroup.
the class StartEventTest method testSignalStartDynamic.
@Test
public void testSignalStartDynamic() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-SignalStart.bpmn2");
ksession = createKnowledgeSession(kbase);
// create KieContainer after session was created to make sure no runtime data
// will be used during serialization (deep clone)
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
kContainer.getKieBase();
final List<Long> list = new ArrayList<Long>();
ksession.addEventListener(new DefaultProcessEventListener() {
public void beforeProcessStarted(ProcessStartedEvent event) {
logger.info("{}", event.getProcessInstance().getId());
list.add(event.getProcessInstance().getId());
}
});
ksession.signalEvent("MySignal", "NewValue");
assertThat(getNumberOfProcessInstances("Minimal")).isEqualTo(1);
// now remove the process from kbase to make sure runtime based listeners are removed from signal manager
kbase.removeProcess("Minimal");
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
ksession.signalEvent("MySignal", "NewValue");
}).withMessageContaining("Unknown process ID: Minimal");
// must be still one as the process was removed
assertThat(getNumberOfProcessInstances("Minimal")).isEqualTo(1);
}
Aggregations