Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.drools.example.api.kiecontainerfromkierepo;
 
 import  org.kie.api.KieServices;
 import  org.kie.api.runtime.KieContainer;
 import  org.kie.api.runtime.KieSession;
 
 
    public void go(PrintStream out) {
        KieServices ks = KieServices.Factory.get();
        // Install example1 in the local maven repo before to do this
        KieContainer kContainer = ks.newKieContainer(ks.newReleaseId("org.drools""named-kiesession""6.0.1-SNAPSHOT"));
        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 static void main(String[] args) {
    }
    private static Object createMessage(KieContainer kContainerString nameString text) {
        Object o = null;
        try {
            Class cl = kContainer.getClassLoader().loadClass("org.drools.example.api.namedkiesession.Message");
            o = cl.getConstructor(new Class[]{String.classString.class}).newInstance(nametext);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return o;
    }
New to GrepCode? Check out our FAQ X