public static NodeInstanceFactoryRegistry getInstance(Environment environment) { // allow custom NodeInstanceFactoryRegistry to be given as part of the environment - e.g simulation if (environment != null && environment.get("NodeInstanceFactoryRegistry") != null) { return (NodeInstanceFactoryRegistry) environment.get("NodeInstanceFactoryRegistry"); } return INSTANCE; }
@Override public EntityManager getEntityManager() { EntityManager em = (EntityManager) env.get(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER); if( em == null ) { throw new IllegalStateException("The command scoped entity manager could not be found!"); } return em; }
protected EntityManager getEntityManagerFromTransaction(Environment env) { if (env.get(EnvironmentName.TRANSACTION_MANAGER) instanceof TransactionManager) { TransactionManager txm = (TransactionManager) env.get(EnvironmentName.TRANSACTION_MANAGER); EntityManager em = (EntityManager) txm.getResource(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER); return em; } return null; }
public DefaultExecutionErrorStorage(Environment environment) { this.emf = (EntityManagerFactory) environment.get(EnvironmentName.ENTITY_MANAGER_FACTORY); // if there is no entity manager factory, running with in memory settings so error handling is deactivated if (this.emf != null) { this.txm = getTransactionManager(environment); } }
protected void addIfPresent(String name, Environment copy) { Object value = this.environment.get(name); if (value != null) { copy.set(name, value); } }
public ProcessPersistenceContext getProcessPersistenceContext() { Boolean locking = (Boolean) env.get(EnvironmentName.USE_PESSIMISTIC_LOCKING); if( locking == null ) { locking = false; } String lockingMode = (String) env.get(EnvironmentName.USE_PESSIMISTIC_LOCKING_MODE); boolean useJTA = true; return new JpaProcessPersistenceContext( getCommandScopedEntityManager(), useJTA, locking, lockingMode, txm ); }
protected boolean hasEnvironmentEntry(String name, Object value) { Object envEntry = environment.getEnvironment().get(name); if (value == null) { return envEntry == null; } return value.equals(envEntry); }
public boolean isActive() { Boolean active = (Boolean) kruntime.getEnvironment().get("Active"); if (active == null) { return true; } return active.booleanValue(); }
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); }
protected boolean useTimerSLATracking() { String mode = (String) getKnowledgeRuntime().getEnvironment().get("SLATimerMode"); if (mode == null) { return true; } return Boolean.parseBoolean(mode); }
@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; }
protected boolean actAsWaitState() { Object asWaitState = getProcessInstance().getKnowledgeRuntime().getEnvironment().get(ACT_AS_WAIT_STATE_PROPERTY); if (asWaitState != null) { return Boolean.parseBoolean(asWaitState.toString()); } return false; }
protected boolean useAsync(final Node node) { if (!(node instanceof EventSubProcessNode) && (node instanceof ActionNode || node instanceof StateBasedNode || node instanceof EndNode)) { boolean asyncMode = Boolean.parseBoolean((String)node.getMetaData().get("customAsync")); if (asyncMode) { return asyncMode; } return Boolean.parseBoolean((String)getProcessInstance().getKnowledgeRuntime().getEnvironment().get("AsyncMode")); } return false; }
private void internalSetDeploymentDescriptor() { this.deploymentDescriptor = (DeploymentDescriptor) ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().get("KieDeploymentDescriptor"); if (this.deploymentDescriptor == null) { this.deploymentDescriptor = new DeploymentDescriptorManager().getDefaultDescriptor(); } }
private void validate() { InternalRuntimeManager manager = (InternalRuntimeManager) getKnowledgeRuntime().getEnvironment().get("RuntimeManager"); if (manager != null) { // check if process instance is owned by the same manager as the one owning ksession if (hasDeploymentId() && !manager.getIdentifier().equals(getDeploymentId())) { throw new IllegalStateException("Process instance " + getId() + " is owned by another deployment " + getDeploymentId() + " != " + manager.getIdentifier()); } } }
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; }
public Integer execute(Context context) { SingleSessionCommandService commandService = (SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner(); InternalKnowledgeRuntime kruntime = (InternalKnowledgeRuntime) commandService.getKieSession(); ProcessPersistenceContextManager contextManager = (ProcessPersistenceContextManager) kruntime .getEnvironment().get(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER); ProcessPersistenceContext pcontext = contextManager.getProcessPersistenceContext(); List<Long> processInstancesToSignalList = pcontext.getProcessInstancesWaitingForEvent("MySignal"); return processInstancesToSignalList.size(); } });
public Integer execute(Context context) { SingleSessionCommandService commandService = (SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner(); InternalKnowledgeRuntime kruntime = (InternalKnowledgeRuntime) commandService.getKieSession(); ProcessPersistenceContextManager contextManager = (ProcessPersistenceContextManager) kruntime .getEnvironment().get(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER); ProcessPersistenceContext pcontext = contextManager.getProcessPersistenceContext(); List<Long> processInstancesToSignalList = pcontext.getProcessInstancesWaitingForEvent("MySignal"); return processInstancesToSignalList.size(); } });
public Integer execute(Context context) { SingleSessionCommandService commandService = (SingleSessionCommandService) ((CommandBasedStatefulKnowledgeSession) ksession).getRunner(); InternalKnowledgeRuntime kruntime = (InternalKnowledgeRuntime) commandService.getKieSession(); ProcessPersistenceContextManager contextManager = (ProcessPersistenceContextManager) kruntime .getEnvironment().get(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER); ProcessPersistenceContext pcontext = contextManager.getProcessPersistenceContext(); List<Long> processInstancesToSignalList = pcontext.getProcessInstancesWaitingForEvent("MySignal"); return processInstancesToSignalList.size(); } });
public void removeProcessInstance(ProcessInstance processInstance) { ProcessPersistenceContext context = ((ProcessPersistenceContextManager) this.kruntime.getEnvironment().get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER )).getProcessPersistenceContext(); ProcessInstanceInfo processInstanceInfo = (ProcessInstanceInfo) context.findProcessInstanceInfo( processInstance.getId() ); if ( processInstanceInfo != null ) { context.remove( processInstanceInfo ); } internalRemoveProcessInstance(processInstance); EventManagerProvider.getInstance().get().delete(getInstanceViewFor(processInstance)); }