All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.chen0040.drools.StatelessKieRuleEngine Maven / Gradle / Ivy

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;
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy