public HumanTaskConfigurator entityManagerFactory(EntityManagerFactory emf) { if (emf == null) { return this; } environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf); return this; }
/** * Adds element to the drools/jbpm environment - the value must be thread save as it will be shared between all * <code>RuntimeEngine</code> instances * @param name name of the environment entry * @param value value of the environment entry */ public void addToEnvironment(String name, Object value) { this.environment.set(name, value); this.environmentEntries.put(name, value); }
protected void addIfPresent(String name, Environment copy) { Object value = this.environment.get(name); if (value != null) { copy.set(name, value); } }
public void set(String string, Object o) { if (string.startsWith("local:")) { delegate.set(string, o); return; } if (this.environment.get(string) != null) { throw new IllegalArgumentException("Cannot override value for property " + string); } this.environment.set(string, o); }
@Override public EntityManager getCommandScopedEntityManager() { EntityManager em = super.getCommandScopedEntityManager(); // ensure em is set in the environment to cover situation when em is taken from tx directly // when using per process instance runtime strategy if (env.get(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER) == null) { env.set(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, em); } return em; }
public static Environment createEnvironment(Map<String, Object> context) { Environment env = EnvironmentFactory.newEnvironment(); UserTransaction ut = (UserTransaction) context.get(TRANSACTION); if( ut != null ) { env.set( TRANSACTION, ut); } env.set( ENTITY_MANAGER_FACTORY, context.get(ENTITY_MANAGER_FACTORY) ); env.set( TRANSACTION_MANAGER, com.arjuna.ats.jta.TransactionManager.transactionManager() ); env.set( GLOBALS, new MapGlobalResolver() ); return env; }
protected InternalTaskService newTaskService(TaskServiceFactory factory) { InternalTaskService internalTaskService = (InternalTaskService) factory.newTaskService(); if (internalTaskService instanceof CommandBasedTaskService) { ((CommandBasedTaskService) internalTaskService).getEnvironment().set(EnvironmentName.DEPLOYMENT_ID, this.getIdentifier()); ((CommandBasedTaskService) internalTaskService).getEnvironment().set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().get(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES)); } return internalTaskService; }
@Override public Void execute(org.kie.api.runtime.Context context) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); ksession.getEnvironment().set("Active", false); InternalProcessRuntime processRuntime = ((InternalKnowledgeRuntime) ksession).getProcessRuntime(); ((ProcessRuntimeImpl) processRuntime).removeProcessEventListeners(); return null; } });
@Override public Void execute(org.kie.api.runtime.Context context) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); ksession.getEnvironment().set("Active", true); InternalProcessRuntime processRuntime = ((InternalKnowledgeRuntime) ksession).getProcessRuntime(); ((ProcessRuntimeImpl) processRuntime).initProcessEventListeners(); ((ProcessRuntimeImpl) processRuntime).initStartTimers(); return null; } });
@Override public KieSession findKieSessionById(Long sessionId) { if (sessionId == null) { return null; } Environment env = environment.getEnvironment(); env.set(EnvironmentName.DEPLOYMENT_ID, owner); KieSession ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, environment.getKieBase(), environment.getConfiguration(), env); addInterceptors(ksession); return ksession; }
@Override public KieSession newKieSession() { Environment env = environment.getEnvironment(); env.set(EnvironmentName.DEPLOYMENT_ID, owner); KieSession ksession = kbase.newKieSession(environment.getConfiguration(), env); this.sessions.put(ksession.getIdentifier(), ksession); ProcessInstanceManager piManager = ((ProcessRuntimeImpl)((StatefulKnowledgeSessionImpl)ksession).getProcessRuntime()).getProcessInstanceManager(); if (piManager instanceof DefaultProcessInstanceManager) { ((DefaultProcessInstanceManager) piManager).setProcessCounter(processCounter); } return ksession; }
@Override public KieSession newKieSession() { Environment env = environment.getEnvironment(); env.set(EnvironmentName.DEPLOYMENT_ID, owner); KieSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( environment.getKieBase(), environment.getConfiguration(), env); addInterceptors(ksession); return ksession; }
@Override protected StatefulKnowledgeSession createSession(KieBase kbase) { Environment env = createEnvironment(context); if( this.useLocking ) { env.set(USE_PESSIMISTIC_LOCKING, true); } return JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env); }
@Override protected StatefulKnowledgeSession createSession(KieBase kbase) { EnvironmentBuilder envBuilder = new ProcessStorageEnvironmentBuilder( storage ); Environment env = KieServices.get().newEnvironment(); env.set( EnvironmentName.TRANSACTION_MANAGER, envBuilder.getTransactionManager() ); env.set( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, envBuilder.getPersistenceContextManager() ); return JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env ); }
@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); }
private Environment createEnvironment() { Environment env = PersistenceUtil.createEnvironment(context); env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[]{ new JPAPlaceholderResolverStrategy(env), new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT ) }); return env; }
@Override protected StatefulKnowledgeSession disposeAndReloadSession(StatefulKnowledgeSession ksession, long ksessionId, KieBase kbase) { ksession.dispose(); EnvironmentBuilder envBuilder = new ProcessStorageEnvironmentBuilder( storage ); Environment env = KieServices.get().newEnvironment(); env.set( EnvironmentName.TRANSACTION_MANAGER, envBuilder.getTransactionManager() ); env.set( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, envBuilder.getPersistenceContextManager() ); return JPAKnowledgeService.loadStatefulKnowledgeSession( ksessionId, kbase, null, env ); }
@Before public void setUp() throws Exception { String methodName = testName.getMethodName(); context = setupWithPoolingDataSource(JBPM_PERSISTENCE_UNIT_NAME); env = createEnvironment(context); if( useLocking ) { env.set(EnvironmentName.USE_PESSIMISTIC_LOCKING, true); } TestEventEmitter.clear(); }
@BeforeClass public static void setup() throws Exception { setUpDataSource(); // clear logs Environment env = EnvironmentFactory.newEnvironment(); env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf); logService = new JPAAuditLogService(env); logService.clear(); }
@Before public void before() { context = setupWithPoolingDataSource(JBPM_PERSISTENCE_UNIT_NAME); Environment env = createEnvironment(context); if( useLocking ) { env.set(EnvironmentName.USE_PESSIMISTIC_LOCKING, true); } ksession = JPAKnowledgeService.newStatefulKnowledgeSession(createKnowledgeBase(), null, env); assertTrue("Valid KnowledgeSession could not be created.", ksession != null && ksession.getIdentifier() > 0); listener = new ProcessListener(); ksession.addEventListener(listener); }