Refine search
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 RuntimeEnvironmentBuilder addAsset(Resource asset, ResourceType type) { if (asset == null || type == null) { return this; } this.runtimeEnvironment.addAsset(asset, type); return this; }
public RuntimeEnvironmentBuilder addConfiguration(String name, String value) { if (name == null || value == null) { return this; } this.runtimeEnvironment.addToConfiguration(name, value); return this; }
private void internalSetKieContainer() { this.kieContainer = (KieContainer) ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().get("KieContainer"); }
RegisterableItemsFactory originalRIF = originalRE.getRegisterableItemsFactory(); if (originalRIF instanceof InternalRegisterableItemsFactory) { ExtendedRegisterableItemsFactory extendedRIF = _registerableItemsFactoryBuilder.build(); auditMode = AuditMode.NONE; originalRE.setMapper(mapper); Environment environmentTemplate = originalRE.getEnvironmentTemplate(); environmentTemplate.set(TaskServiceFactory.class.getName(), new PatchedLocalTaskServiceFactory(originalRE)); DeploymentDescriptor deploymentDescriptor = (DeploymentDescriptor)environmentTemplate.get("KieDeploymentDescriptor"); if (deploymentDescriptor == null) { deploymentDescriptor = new DeploymentDescriptorManager().getDefaultDescriptor(); environmentTemplate.set("KieDeploymentDescriptor", deploymentDescriptor);
protected void adjustEnvironment(RuntimeEnvironment environment) { if (userGroupCallback != null) { ((SimpleRuntimeEnvironment)environment).setUserGroupCallback(userGroupCallback); } if (schedulerService != null) { ((SimpleRuntimeEnvironment)environment).setSchedulerService(schedulerService); } ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.TRANSACTION_MANAGER, transactionManager); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.TASK_USER_GROUP_CALLBACK, userGroupCallback); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.TASK_USER_INFO, userInfo); if (entityManager != null) { ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.APP_SCOPED_ENTITY_MANAGER, entityManager); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, entityManager); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set("IS_JTA_TRANSACTION", false); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set("IS_SHARED_ENTITY_MANAGER", true); } if (pessimisticLocking) { ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.USE_PESSIMISTIC_LOCKING, true); } TransactionManagerFactory transactionManagerFactory = TransactionManagerFactory.get(); if (transactionManagerFactory instanceof KieSpringTransactionManagerFactory) { ((KieSpringTransactionManagerFactory) transactionManagerFactory).setGlobalTransactionManager(transactionManager); } }
@Override public TaskService newTaskService() { // all to reuse an already given instance of task service instead of producing new one TaskService providedTaskService = (TaskService) ((SimpleRuntimeEnvironment) runtimeEnvironment) .getEnvironmentTemplate().get("org.kie.api.task.TaskService"); if (providedTaskService != null) { return providedTaskService; } EntityManagerFactory emf = ((SimpleRuntimeEnvironment)runtimeEnvironment).getEmf(); if (emf != null) { HumanTaskConfigurator configurator = HumanTaskServiceFactory.newTaskServiceConfigurator() .environment(runtimeEnvironment.getEnvironment()) .entityManagerFactory(emf) .userGroupCallback(runtimeEnvironment.getUserGroupCallback()) .userInfo(runtimeEnvironment.getUserInfo()); TaskService internalTaskService = configurator.getTaskService(); return internalTaskService; } else { return null; } }
public RuntimeEnvironmentBuilder addEnvironmentEntry(String name, Object value) { if (name == null || value == null) { return this; } this.runtimeEnvironment.addToEnvironment(name, value); return this; }
public RuntimeEnvironmentBuilder schedulerService(Object globalScheduler) { if (globalScheduler == null) { return this; } if (!(globalScheduler instanceof GlobalSchedulerService)) { throw new IllegalArgumentException("Argument is not of type GlobalSchedulerService"); } this.runtimeEnvironment.setSchedulerService((GlobalSchedulerService) globalScheduler); return this; }
public RuntimeEnvironmentBuilder userGroupCallback(UserGroupCallback callback) { if (callback == null) { return this; } this.runtimeEnvironment.setUserGroupCallback(callback); return this; }
public RuntimeEnvironmentBuilder classLoader(ClassLoader cl) { if (cl == null) { return this; } this.runtimeEnvironment.setClassLoader(cl); return this; }
@Override public Environment getEnvironment() { // this environment is like template always make a new copy when this method is called return copyEnvironment(); }
public RuntimeEnvironment get() { this.runtimeEnvironment.init(); return this.runtimeEnvironment; }
public RuntimeEnvironmentBuilder() { this.runtimeEnvironment = new SimpleRuntimeEnvironment(); }
protected TaskServiceFactory getTaskServiceFactory(RuntimeEnvironment environment) { // if there is an implementation of TaskServiceFactory in the environment then use it TaskServiceFactory taskServiceFactory = (TaskServiceFactory) ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate() .get("org.kie.internal.runtime.manager.TaskServiceFactory"); if (taskServiceFactory != null) { return taskServiceFactory; } taskServiceFactory = new LocalTaskServiceFactory(environment); return taskServiceFactory; }
RegisterableItemsFactory originalRIF = originalRE.getRegisterableItemsFactory(); if (originalRIF instanceof InternalRegisterableItemsFactory) { ExtendedRegisterableItemsFactory extendedRIF = _registerableItemsFactoryBuilder.build(); auditMode = AuditMode.NONE; originalRE.setMapper(mapper); Environment environmentTemplate = originalRE.getEnvironmentTemplate(); environmentTemplate.set(TaskServiceFactory.class.getName(), new PatchedLocalTaskServiceFactory(originalRE)); DeploymentDescriptor deploymentDescriptor = (DeploymentDescriptor)environmentTemplate.get("KieDeploymentDescriptor"); if (deploymentDescriptor == null) { deploymentDescriptor = new DeploymentDescriptorManager().getDefaultDescriptor(); environmentTemplate.set("KieDeploymentDescriptor", deploymentDescriptor);
protected void adjustEnvironment(RuntimeEnvironment environment) { if (userGroupCallback != null) { ((SimpleRuntimeEnvironment)environment).setUserGroupCallback(userGroupCallback); } if (schedulerService != null) { ((SimpleRuntimeEnvironment)environment).setSchedulerService(schedulerService); } ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.TRANSACTION_MANAGER, transactionManager); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.TASK_USER_GROUP_CALLBACK, userGroupCallback); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.TASK_USER_INFO, userInfo); if (entityManager != null) { ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.APP_SCOPED_ENTITY_MANAGER, entityManager); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.CMD_SCOPED_ENTITY_MANAGER, entityManager); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set("IS_JTA_TRANSACTION", false); ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set("IS_SHARED_ENTITY_MANAGER", true); } if (pessimisticLocking) { ((SimpleRuntimeEnvironment)environment).getEnvironmentTemplate().set(EnvironmentName.USE_PESSIMISTIC_LOCKING, true); } TransactionManagerFactory transactionManagerFactory = TransactionManagerFactory.get(); if (transactionManagerFactory instanceof KieSpringTransactionManagerFactory) { ((KieSpringTransactionManagerFactory) transactionManagerFactory).setGlobalTransactionManager(transactionManager); } }
@Override public TaskService newTaskService() { // all to reuse an already given instance of task service instead of producing new one TaskService providedTaskService = (TaskService) ((SimpleRuntimeEnvironment) runtimeEnvironment) .getEnvironmentTemplate().get("org.kie.api.task.TaskService"); if (providedTaskService != null) { return providedTaskService; } EntityManagerFactory emf = ((SimpleRuntimeEnvironment)runtimeEnvironment).getEmf(); if (emf != null) { HumanTaskConfigurator configurator = HumanTaskServiceFactory.newTaskServiceConfigurator() .environment(runtimeEnvironment.getEnvironment()) .entityManagerFactory(emf) .userGroupCallback(runtimeEnvironment.getUserGroupCallback()) .userInfo(runtimeEnvironment.getUserInfo()); TaskService internalTaskService = configurator.getTaskService(); return internalTaskService; } else { return null; } }
@Override public void activate() { ((SimpleRuntimeEnvironment) environment).addToEnvironment("Active", true); }
public RuntimeEnvironmentBuilder schedulerService(Object globalScheduler) { if (globalScheduler == null) { return this; } if (!(globalScheduler instanceof GlobalSchedulerService)) { throw new IllegalArgumentException("Argument is not of type GlobalSchedulerService"); } this.runtimeEnvironment.setSchedulerService((GlobalSchedulerService) globalScheduler); return this; }