@Override public RuntimeEngine getRuntimeEngine(Context<?> context) { if (isClosed()) { throw new IllegalStateException("Runtime manager " + identifier + " is already closed"); } checkPermission(); RuntimeEngine runtime = null; if (local.get() != null) { return local.get(); } if (engineInitEager) { InternalTaskService internalTaskService = (InternalTaskService) taskServiceFactory.newTaskService(); runtime = new RuntimeEngineImpl(factory.newKieSession(), internalTaskService); ((RuntimeEngineImpl) runtime).setManager(this); configureRuntimeOnTaskService(internalTaskService, runtime); registerDisposeCallback(runtime, new DisposeSessionTransactionSynchronization(this, runtime)); registerDisposeCallback( runtime, new DestroySessionTransactionSynchronization(runtime.getKieSession())); registerItems(runtime); attachManager(runtime); } else { runtime = new RuntimeEngineImpl(context, new PerRequestInitializer()); ((RuntimeEngineImpl) runtime).setManager(this); } local.set(runtime); return runtime; }
@Override public KieSession initKieSession( Context<?> context, InternalRuntimeManager manager, RuntimeEngine engine) { RuntimeEngine inUse = local.get(); if (inUse != null && ((RuntimeEngineImpl) inUse).internalGetKieSession() != null) { return inUse.getKieSession(); } KieSession ksession = factory.newKieSession(); ((RuntimeEngineImpl) engine).internalSetKieSession(ksession); registerDisposeCallback( engine, new DisposeSessionTransactionSynchronization(manager, engine)); registerDisposeCallback(engine, new DestroySessionTransactionSynchronization(ksession)); registerItems(engine); attachManager(engine); return ksession; }