Tabnine Logo
SingleSessionCommandService
Code IndexAdd Tabnine to your IDE (free)

How to use
SingleSessionCommandService
in
org.drools.core.command

Best Java code snippets using org.drools.core.command.SingleSessionCommandService (Showing top 20 results out of 315)

Refine searchRefine arrow

  • CommandBasedStatefulKnowledgeSession
  • KieSession
origin: kiegroup/jbpm

private KieRuntime extractIfNeeded(KieRuntime ksession) {
  if (ksession instanceof CommandBasedStatefulKnowledgeSession) {
    return ((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession();
  }
  return ksession;
}
origin: kiegroup/jbpm

@Override
public Void execute(org.kie.api.runtime.Context context) {
  TransactionManager tm = (TransactionManager) initialKsession.getEnvironment().get(EnvironmentName.TRANSACTION_MANAGER);
  if (manager.hasEnvironmentEntry("IS_JTA_TRANSACTION", false)) {
    if (initialKsession instanceof CommandBasedStatefulKnowledgeSession) {
      ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) initialKsession).getRunner();
      ((SingleSessionCommandService) commandService).destroy();
     } else {
      ((RegistryContext) context).lookup( KieSession.class ).destroy();
      && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK
      && tm.getStatus() != TransactionManager.STATUS_COMMITTED) {
    TransactionManagerHelper.registerTransactionSyncInContainer(tm, new OrderedTransactionSynchronization(5, "PPIRM-"+initialKsession.getIdentifier()) {
origin: kiegroup/jbpm

@Test
@RequirePersistence
public void testRuleTaskWithFactsWithPersistence() throws Exception {
  KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-RuleTaskWithFact.bpmn2",
      "BPMN2-RuleTask3.drl");
  ksession = createKnowledgeSession(kbase);
  ( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
                                                   .addEventListener(new TriggerRulesEventListener(ksession));
  ksession.addEventListener(new DebugAgendaEventListener());
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("x", "SomeString");
  ProcessInstance processInstance = ksession.startProcess("RuleTask",
      params);
  assertProcessInstanceFinished(processInstance, ksession);
  params = new HashMap<String, Object>();
  try {
    processInstance = ksession.startProcess("RuleTask", params);
    fail("Should fail");
  } catch (Exception e) {
    e.printStackTrace();
  }
  params = new HashMap<String, Object>();
  params.put("x", "SomeString");
  processInstance = ksession.startProcess("RuleTask", params);
  assertProcessInstanceFinished(processInstance, ksession);
}
origin: kiegroup/jbpm

@Test @Ignore("beta4 phreak")
public void testStartTimerCycleFromDiscDRL() throws Exception {
  KieBase kbase = createKnowledgeBaseFromDisc("rules-timer.drl");
  StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
  long sessionId = ksession.getIdentifier();
  Environment env = ksession.getEnvironment();
  final List<String> list = new ArrayList<String>();
  ksession.setGlobal("list", list);
  ( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
      .addEventListener(new TriggerRulesEventListener(ksession));
  ksession.fireAllRules();
  Thread.sleep(5000);
  assertEquals(2, list.size());
  logger.info("dispose");
  ksession.dispose();
  ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId,
      kbase, null, env);
  AuditLoggerFactory.newInstance(Type.JPA, ksession, null);
  final List<String> list2 = new ArrayList<String>();
  ksession.setGlobal("list", list2);
  ( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
      .addEventListener(new TriggerRulesEventListener(ksession));
  ksession.fireAllRules();
  Thread.sleep(6000);
  assertEquals(3, list2.size());
}
origin: kiegroup/jbpm

  @Override
  public Void execute(Context context) {
    if (ksession instanceof CommandBasedStatefulKnowledgeSession) {
      ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) ksession).getRunner();
      ((SingleSessionCommandService) commandService).destroy();
     }
    return null;
  }
});
origin: org.kie/drools-infinispan-persistence

public long getStatefulKnowledgeSessionId(StatefulKnowledgeSession ksession) {
  if ( ksession instanceof CommandBasedStatefulKnowledgeSession ) {
    SingleSessionCommandService commandService = (SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner();
    return commandService.getSessionId();
  }
  throw new IllegalArgumentException( "StatefulKnowledgeSession must be an a CommandBasedStatefulKnowledgeSession" );
}
origin: org.kie/drools-infinispan-persistence

  @Override
  public RequestContext createContext() {
    KieSession ksession = interceptedService.getKieSession();
    RequestContext context = RequestContext.create(ksession.getClass().getClassLoader()).with( ksession );
    return context;
  }
}
origin: org.jbpm/jbpm-bpmn2

@Test
@RequirePersistence
public void testRuleTaskWithFactsWithPersistence() throws Exception {
  KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-RuleTaskWithFact.bpmn2",
      "BPMN2-RuleTask3.drl");
  ksession = createKnowledgeSession(kbase);
  ( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
                                                   .addEventListener(new TriggerRulesEventListener(ksession));
  ksession.addEventListener(new DebugAgendaEventListener());
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("x", "SomeString");
  ProcessInstance processInstance = ksession.startProcess("RuleTask",
      params);
  assertProcessInstanceFinished(processInstance, ksession);
  params = new HashMap<String, Object>();
  try {
    processInstance = ksession.startProcess("RuleTask", params);
    fail("Should fail");
  } catch (Exception e) {
    e.printStackTrace();
  }
  params = new HashMap<String, Object>();
  params.put("x", "SomeString");
  processInstance = ksession.startProcess("RuleTask", params);
  assertProcessInstanceFinished(processInstance, ksession);
}
origin: kiegroup/jbpm

@Test @Ignore("beta4 phreak")
public void testStartTimerCycleFromClasspathDRL() throws Exception {
  KieBase kbase = createKnowledgeBaseWithoutDumper("rules-timer.drl");
  StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
  long sessionId = ksession.getIdentifier();
  Environment env = ksession.getEnvironment();
  final List<String> list = new ArrayList<String>();
  ksession.setGlobal("list", list);
  ( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
      .addEventListener(new TriggerRulesEventListener(ksession));
  ksession.fireAllRules();
  Thread.sleep(5000);
  assertEquals(2, list.size());
  logger.info("dispose");
  ksession.dispose();
  ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId,
      kbase, null, env);
  AuditLoggerFactory.newInstance(Type.JPA, ksession, null);
  final List<String> list2 = new ArrayList<String>();
  ksession.setGlobal("list", list2);
  ( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
      .addEventListener(new TriggerRulesEventListener(ksession));
  ksession.fireAllRules();
  Thread.sleep(5000);
  assertEquals(3, list2.size());
}
origin: kiegroup/jbpm

@Override
public void beforeCompletion() {
  if (initialKsession instanceof CommandBasedStatefulKnowledgeSession) {
    ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) initialKsession).getRunner();
    ((SingleSessionCommandService) commandService).destroy();
   }                            
}

origin: org.kie/drools-infinispan-persistence

public RequestContext execute( Executable executable, RequestContext ctx ) {
  executeNext(executable, ctx);
  try {
    KieSession ksession = interceptedService.getKieSession();
    java.lang.reflect.Field sessionInfoField = PersistableRunner.class.getDeclaredField( "sessionInfo" );
    sessionInfoField.setAccessible(true);
    java.lang.reflect.Field jpmField = PersistableRunner.class.getDeclaredField("jpm");
    jpmField.setAccessible(true);
    Object jpm = jpmField.get(interceptedService);
    Object sessionInfo = sessionInfoField.get(interceptedService);
    if ( ( (InternalExecutable) executable ).canRunInTransaction() ) {
      executeNext(new SingleCommandExecutable( new PersistCommand(sessionInfo, jpm, ksession) ), ctx);
    }
  } catch (Exception e) {
    throw new RuntimeException("Couldn't force persistence of session info", e);
  }
  return ctx;
}
origin: kiegroup/jbpm

@Override
public Void execute(org.kie.api.runtime.Context context) {
  TransactionManager tm = (TransactionManager) initialKsession.getEnvironment().get(EnvironmentName.TRANSACTION_MANAGER);
  if (manager.hasEnvironmentEntry("IS_JTA_TRANSACTION", false)) {
    if (initialKsession instanceof CommandBasedStatefulKnowledgeSession) {
      ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) initialKsession).getRunner();
      ((SingleSessionCommandService) commandService).destroy();
    } else {
      ((RegistryContext) context).lookup( KieSession.class ).destroy();
    TransactionManagerHelper.registerTransactionSyncInContainer(tm, new OrderedTransactionSynchronization(5, "PCRM-" + initialKsession.getIdentifier()) {
origin: kiegroup/jbpm

( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
    .addEventListener(new TriggerRulesEventListener(ksession));
( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
    .addEventListener(new TriggerRulesEventListener(ksession));
origin: kiegroup/jbpm

protected TimerManager getTimerManager(KieSession ksession) {
  KieSession internal = ksession;
  if (ksession instanceof CommandBasedStatefulKnowledgeSession) {
    internal = ( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession();
  }
  return ((InternalProcessRuntime) ((StatefulKnowledgeSessionImpl) internal).getProcessRuntime()).getTimerManager();
}
origin: kiegroup/jbpm

@Override
public void beforeCompletion() {
  if (initialKsession instanceof CommandBasedStatefulKnowledgeSession) {
    ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) initialKsession).getRunner();
    ((SingleSessionCommandService) commandService).destroy();
  }
}
origin: org.jbpm/jbpm-runtime-manager

@Override
public Void execute(org.kie.api.runtime.Context context) {
  TransactionManager tm = (TransactionManager) initialKsession.getEnvironment().get(EnvironmentName.TRANSACTION_MANAGER);
  if (manager.hasEnvironmentEntry("IS_JTA_TRANSACTION", false)) {
    if (initialKsession instanceof CommandBasedStatefulKnowledgeSession) {
      ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) initialKsession).getRunner();
      ((SingleSessionCommandService) commandService).destroy();
     } else {
      ((RegistryContext) context).lookup( KieSession.class ).destroy();
      && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK
      && tm.getStatus() != TransactionManager.STATUS_COMMITTED) {
    TransactionManagerHelper.registerTransactionSyncInContainer(tm, new OrderedTransactionSynchronization(5, "PPIRM-"+initialKsession.getIdentifier()) {
origin: kiegroup/jbpm

( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
                                                 .addEventListener(new TriggerRulesEventListener(ksession));
( (SingleSessionCommandService) ( (CommandBasedStatefulKnowledgeSession) ksession ).getRunner() ).getKieSession()
    .addEventListener(new TriggerRulesEventListener(ksession));
origin: kiegroup/jbpm

protected TimerManager getTimerManager(KieSession ksession) {
  KieSession internal = ksession;
  if (ksession instanceof CommandBasedStatefulKnowledgeSession) {
    internal = ((SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner()).getKieSession();
  }
  return ((InternalProcessRuntime) ((StatefulKnowledgeSessionImpl) internal).getProcessRuntime()).getTimerManager();
}
origin: org.jbpm/jbpm-runtime-manager

@Override
public void beforeCompletion() {
  if (initialKsession instanceof CommandBasedStatefulKnowledgeSession) {
    ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) initialKsession).getRunner();
    ((SingleSessionCommandService) commandService).destroy();
   }                            
}

origin: org.jbpm/jbpm-runtime-manager

@Override
public Void execute(org.kie.api.runtime.Context context) {
  TransactionManager tm = (TransactionManager) initialKsession.getEnvironment().get(EnvironmentName.TRANSACTION_MANAGER);
  if (manager.hasEnvironmentEntry("IS_JTA_TRANSACTION", false)) {
    if (initialKsession instanceof CommandBasedStatefulKnowledgeSession) {
      ExecutableRunner commandService = ((CommandBasedStatefulKnowledgeSession) initialKsession).getRunner();
      ((SingleSessionCommandService) commandService).destroy();
    } else {
      ((RegistryContext) context).lookup( KieSession.class ).destroy();
    TransactionManagerHelper.registerTransactionSyncInContainer(tm, new OrderedTransactionSynchronization(5, "PCRM-" + initialKsession.getIdentifier()) {
org.drools.core.commandSingleSessionCommandService

Most used methods

  • getKieSession
  • destroy
  • getSessionId

Popular in Java

  • Start an intent from android
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • scheduleAtFixedRate (Timer)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now