protected void addInterceptors(KieSession ksession) { PersistableRunner runner = (PersistableRunner) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner(); runner.addInterceptor(new OptimisticLockRetryInterceptor()); // even though it's added always TransactionLockInterceptor is by default disabled so won't do anything runner.addInterceptor(new TransactionLockInterceptor(ksession.getEnvironment())); runner.addInterceptor(new ExecutionErrorHandlerInterceptor(ksession.getEnvironment())); }
assertEquals(OptimisticLockRetryInterceptor.class, internalCommandService.getClass()); internalCommandService = (ChainableRunner) ((OptimisticLockRetryInterceptor) internalCommandService).getNext(); assertEquals("org.drools.persistence.PersistableRunner$TransactionInterceptor", internalCommandService.getClass().getName());
executeNext(executable, ctx); return ctx; if (hasInterceptorInStack()) { throw ex; if (!isCausedByOptimisticLockingFailure(ex) && !isCausedByConstraintViolationFailure(ex)) { throw ex;
@Override public final RequestContext execute( Executable executable, RequestContext ctx ) { AtomicInteger counter = invocationsCounter.get(); if (counter == null) { counter = new AtomicInteger( 0 ); invocationsCounter.set( counter ); } counter.incrementAndGet(); try { return internalExecute( executable, ctx ); } finally { if (counter.decrementAndGet() == 0) { invocationsCounter.remove(); } } }
protected void addInterceptors(KieSession ksession) { PersistableRunner runner = (PersistableRunner) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner(); runner.addInterceptor(new OptimisticLockRetryInterceptor()); // even though it's added always TransactionLockInterceptor is by default disabled so won't do anything runner.addInterceptor(new TransactionLockInterceptor(ksession.getEnvironment())); runner.addInterceptor(new ExecutionErrorHandlerInterceptor(ksession.getEnvironment())); }