protected KieSession createKnowledgeSession(String processFile) throws Exception {
    KieServices ks = KieServices.Factory.get();
    KieRepository kr = ks.getRepository();
    KieFileSystem kfs = ks.newKieFileSystem();
    if (processFile != null) {
      Resource process = ResourceFactory.newClassPathResource(processFile);
      kfs.write(process);
    }

    KieBuilder kb = ks.newKieBuilder(kfs);
    kb.buildAll();

    if (kb.getResults().hasMessages(Level.ERROR)) {
      throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
    }

    KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
    KieBase kbase = kContainer.getKieBase();

    Environment env = EnvironmentFactory.newEnvironment();

    Properties defaultProps = new Properties();
    defaultProps.setProperty(
        "drools.processSignalManagerFactory", DefaultSignalManagerFactory.class.getName());
    defaultProps.setProperty(
        "drools.processInstanceManagerFactory",
        DefaultProcessInstanceManagerFactory.class.getName());
    SessionConfiguration conf = new SessionConfiguration(defaultProps);

    KieSession ksession = (StatefulKnowledgeSession) kbase.newKieSession(conf, env);
    return ksession;
  }
 public ReteooWorkingMemory(final int id, final InternalRuleBase ruleBase) {
   this(
       id,
       ruleBase,
       SessionConfiguration.getDefaultInstance(),
       EnvironmentFactory.newEnvironment());
 }
 @Before
 public void setUp() throws Exception {
   context = setupWithPoolingDataSource(JBPM_PERSISTENCE_UNIT_NAME);
   Environment env = EnvironmentFactory.newEnvironment();
   env.set(
       EnvironmentName.ENTITY_MANAGER_FACTORY,
       context.get(EnvironmentName.ENTITY_MANAGER_FACTORY));
   logService = new JPAAuditLogService(env);
 }
 /**
  * Create a new session into which to read the stream data
  *
  * @param context
  * @param id
  * @param executor
  * @return
  * @throws IOException
  * @throws ClassNotFoundException
  */
 public static ReteooStatefulSession readSession(MarshallerReaderContext context, int id)
     throws IOException, ClassNotFoundException {
   ReteooStatefulSession session =
       readSession(
           context,
           id,
           EnvironmentFactory.newEnvironment(),
           SessionConfiguration.getDefaultInstance());
   return session;
 }
  private StatefulKnowledgeSessionImpl createWorkingMemory(InternalKnowledgeBase kBase) {
    // WorkingMemoryEntryPoint
    KieSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
    ksconf.setOption(ClockTypeOption.get("pseudo"));
    SessionConfiguration sessionConf = ((SessionConfiguration) ksconf);
    StatefulKnowledgeSessionImpl wm =
        new StatefulKnowledgeSessionImpl(
            1L, kBase, true, sessionConf, EnvironmentFactory.newEnvironment());

    return wm;
  }
 public Environment newEnvironment() {
   return EnvironmentFactory.newEnvironment();
 }