com.github.chen0040.drools.StatelessKieRuleEngine Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of friendly-drools Show documentation
Show all versions of friendly-drools Show documentation
Friendly wrapper that provides useful utilities over Drools engine
The newest version!
package com.github.chen0040.drools;
import org.kie.api.command.Command;
import org.kie.api.event.KieRuntimeEventManager;
import org.kie.api.runtime.ExecutionResults;
import org.kie.api.runtime.StatelessKieSession;
import org.kie.internal.command.CommandFactory;
import java.util.List;
/**
* Created by xschen on 11/7/16.
*/
public class StatelessKieRuleEngine extends AbstractRuleEngine implements StatelessRuleEngine {
private StatelessKieSession kieSession;
@Override protected KieRuntimeEventManager createSession() {
return kieSession = kieContainer.newStatelessKieSession();
}
public ExecutionResults execute(List commands) {
return kieSession.execute(CommandFactory.newBatchExecution(commands));
}
@Override public void insert(List commands, String identifier, Object obj) {
commands.add(CommandFactory.newInsert(obj, identifier));
}
@Override public void setGlobal(List commands, String identifier, Object obj, boolean out) {
commands.add(CommandFactory.newSetGlobal(identifier, obj, out));
}
@Override public void query(List commands, String identifier, String query) {
commands.add(CommandFactory.newQuery(identifier, query));
}
@Override public StatelessKieSession getSession() {
return kieSession;
}
}