use of org.jbpm.services.api.AdvanceRuntimeDataService in project droolsjbpm-integration by kiegroup.
the class JbpmKieServerExtension method configureServices.
protected void configureServices(KieServerImpl kieServer, KieServerRegistry registry) {
KieServerConfig config = registry.getConfig();
// loaded from system property as callback info isn't stored as configuration in kie server repository
String callbackConfig = System.getProperty(KieServerConstants.CFG_HT_CALLBACK);
// if no other callback set, use Elytron or jaas by default
if (callbackConfig == null || callbackConfig.isEmpty()) {
if (ElytronIdentityProvider.available()) {
System.setProperty(KieServerConstants.CFG_HT_CALLBACK, "custom");
String name = ElytronUserGroupCallbackImpl.class.getName();
ElytronUserGroupCallbackImpl.addExternalUserGroupAdapter(new JMSUserGroupAdapter());
System.setProperty(KieServerConstants.CFG_HT_CALLBACK_CLASS, name);
} else {
System.setProperty(KieServerConstants.CFG_HT_CALLBACK, "jaas");
JAASUserGroupCallbackImpl.addExternalUserGroupAdapter(new JMSUserGroupAdapter());
}
}
this.isExecutorAvailable = isExecutorOnClasspath();
EntityManagerFactory emf = build(getPersistenceProperties(config));
EntityManagerFactoryManager.get().addEntityManagerFactory(persistenceUnitName, emf);
formManagerService = new FormManagerServiceImpl();
// build definition service
definitionService = new BPMN2DataServiceImpl();
// build deployment service
deploymentService = new KModuleDeploymentService();
((KModuleDeploymentService) deploymentService).setBpmn2Service(definitionService);
((KModuleDeploymentService) deploymentService).setEmf(emf);
((KModuleDeploymentService) deploymentService).setIdentityProvider(registry.getIdentityProvider());
((KModuleDeploymentService) deploymentService).setManagerFactory(new RuntimeManagerFactoryImpl());
((KModuleDeploymentService) deploymentService).setFormManagerService(formManagerService);
// configure user group callback
UserGroupCallback userGroupCallback = UserDataServiceProvider.getUserGroupCallback();
UserInfo userInfo = UserDataServiceProvider.getUserInfo();
TaskService taskService = HumanTaskServiceFactory.newTaskServiceConfigurator().entityManagerFactory(emf).userGroupCallback(userGroupCallback).userInfo(userInfo).getTaskService();
// build runtime data service
runtimeDataService = new RuntimeDataServiceImpl();
((RuntimeDataServiceImpl) runtimeDataService).setCommandService(new TransactionalCommandService(emf));
((RuntimeDataServiceImpl) runtimeDataService).setIdentityProvider(registry.getIdentityProvider());
((RuntimeDataServiceImpl) runtimeDataService).setTaskService(taskService);
((RuntimeDataServiceImpl) runtimeDataService).setTaskAuditService(TaskAuditServiceFactory.newTaskAuditServiceConfigurator().setTaskService(taskService).getTaskAuditService());
((KModuleDeploymentService) deploymentService).setRuntimeDataService(runtimeDataService);
// build process service
processService = new ProcessServiceImpl();
((ProcessServiceImpl) processService).setDataService(runtimeDataService);
((ProcessServiceImpl) processService).setDeploymentService(deploymentService);
// build user task service
userTaskService = new UserTaskServiceImpl();
((UserTaskServiceImpl) userTaskService).setDataService(runtimeDataService);
((UserTaskServiceImpl) userTaskService).setDeploymentService(deploymentService);
// build query service
queryService = new QueryServiceImpl();
((QueryServiceImpl) queryService).setIdentityProvider(registry.getIdentityProvider());
((QueryServiceImpl) queryService).setCommandService(new TransactionalCommandService(emf));
Function<String, String> kieServerDataSourceResolver = input -> {
String dataSource = input;
Matcher matcher = PARAMETER_MATCHER.matcher(dataSource);
while (matcher.find()) {
String paramName = matcher.group(1);
KieServerConfig configuration = context.getStateRepository().load(KieServerEnvironment.getServerId()).getConfiguration();
dataSource = configuration.getConfigItemValue(paramName, "java:jboss/datasources/ExampleDS");
logger.info("Data source expression {} resolved to {}", input, dataSource);
}
return dataSource;
};
((QueryServiceImpl) queryService).setDataSourceResolver(kieServerDataSourceResolver);
((QueryServiceImpl) queryService).init();
// set runtime data service as listener on deployment service
((KModuleDeploymentService) deploymentService).addListener(((RuntimeDataServiceImpl) runtimeDataService));
((KModuleDeploymentService) deploymentService).addListener(((BPMN2DataServiceImpl) definitionService));
((KModuleDeploymentService) deploymentService).addListener(((QueryServiceImpl) queryService));
if (config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_DISABLED, "false").equalsIgnoreCase("false")) {
String executorQueueName = config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_JMS_QUEUE, "queue/KIE.SERVER.EXECUTOR");
// build executor service
executorService = ExecutorServiceFactory.newExecutorService(emf);
executorService.setInterval(Integer.parseInt(config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_INTERVAL, "0")));
executorService.setRetries(Integer.parseInt(config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_RETRIES, "3")));
executorService.setThreadPoolSize(Integer.parseInt(config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_POOL, "1")));
executorService.setTimeunit(TimeUnit.valueOf(config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_TIME_UNIT, "SECONDS")));
((ExecutorImpl) ((ExecutorServiceImpl) executorService).getExecutor()).setQueueName(executorQueueName);
((KModuleDeploymentService) deploymentService).setExecutorService(executorService);
}
// admin services
this.processInstanceMigrationService = new ProcessInstanceMigrationServiceImpl();
this.processInstanceAdminService = new ProcessInstanceAdminServiceImpl();
((ProcessInstanceAdminServiceImpl) this.processInstanceAdminService).setProcessService(processService);
((ProcessInstanceAdminServiceImpl) this.processInstanceAdminService).setRuntimeDataService(runtimeDataService);
((ProcessInstanceAdminServiceImpl) this.processInstanceAdminService).setCommandService(new TransactionalCommandService(emf));
((ProcessInstanceAdminServiceImpl) this.processInstanceAdminService).setIdentityProvider(registry.getIdentityProvider());
this.userTaskAdminService = new UserTaskAdminServiceImpl();
((UserTaskAdminServiceImpl) this.userTaskAdminService).setRuntimeDataService(runtimeDataService);
((UserTaskAdminServiceImpl) this.userTaskAdminService).setUserTaskService(userTaskService);
((UserTaskAdminServiceImpl) this.userTaskAdminService).setIdentityProvider(context.getIdentityProvider());
((UserTaskAdminServiceImpl) this.userTaskAdminService).setCommandService(new TransactionalCommandService(emf));
this.advanceRuntimeDataService = new AdvanceRuntimeDataServiceImpl();
((AdvanceRuntimeDataServiceImpl) this.advanceRuntimeDataService).setEmf(emf);
((AdvanceRuntimeDataServiceImpl) this.advanceRuntimeDataService).setCommandService(new TransactionalCommandService(emf));
this.kieContainerCommandService = new JBPMKieContainerCommandServiceImpl(context, deploymentService, new DefinitionServiceBase(definitionService, context), new ProcessServiceBase(processService, definitionService, runtimeDataService, context), new UserTaskServiceBase(userTaskService, context), new RuntimeDataServiceBase(runtimeDataService, advanceRuntimeDataService, context), new ExecutorServiceBase(executorService, context), new QueryDataServiceBase(queryService, context), new DocumentServiceBase(context), new ProcessAdminServiceBase(processInstanceMigrationService, processInstanceAdminService, runtimeDataService, context), new UserTaskAdminServiceBase(userTaskAdminService, context));
}
use of org.jbpm.services.api.AdvanceRuntimeDataService in project droolsjbpm-integration by kiegroup.
the class JbpmRestApplicationComponentsService method getAppComponents.
@Override
public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
// skip calls from other than owning extension
if (!OWNER_EXTENSION.equals(extension)) {
return Collections.emptyList();
}
ProcessService processService = null;
RuntimeDataService runtimeDataService = null;
DefinitionService definitionService = null;
UserTaskService userTaskService = null;
ExecutorService executorService = null;
QueryService queryService = null;
ProcessInstanceMigrationService processInstanceMigrationService = null;
ProcessInstanceAdminService processInstanceAdminService = null;
UserTaskAdminService userTaskAdminService = null;
KieServerRegistry context = null;
AdvanceRuntimeDataService advanceRuntimeDataService = null;
for (Object object : services) {
// in case given service is null (meaning was not configured) continue with next one
if (object == null) {
continue;
}
if (ProcessService.class.isAssignableFrom(object.getClass())) {
processService = (ProcessService) object;
continue;
} else if (RuntimeDataService.class.isAssignableFrom(object.getClass())) {
runtimeDataService = (RuntimeDataService) object;
continue;
} else if (DefinitionService.class.isAssignableFrom(object.getClass())) {
definitionService = (DefinitionService) object;
continue;
} else if (UserTaskService.class.isAssignableFrom(object.getClass())) {
userTaskService = (UserTaskService) object;
continue;
} else if (ExecutorService.class.isAssignableFrom(object.getClass())) {
executorService = (ExecutorService) object;
continue;
} else if (QueryService.class.isAssignableFrom(object.getClass())) {
queryService = (QueryService) object;
continue;
} else if (ProcessInstanceMigrationService.class.isAssignableFrom(object.getClass())) {
processInstanceMigrationService = (ProcessInstanceMigrationService) object;
continue;
} else if (ProcessInstanceAdminService.class.isAssignableFrom(object.getClass())) {
processInstanceAdminService = (ProcessInstanceAdminService) object;
continue;
} else if (UserTaskAdminService.class.isAssignableFrom(object.getClass())) {
userTaskAdminService = (UserTaskAdminService) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
} else if (AdvanceRuntimeDataService.class.isAssignableFrom(object.getClass())) {
advanceRuntimeDataService = (AdvanceRuntimeDataService) object;
continue;
}
}
List<Object> components = new ArrayList<Object>(6);
DefinitionServiceBase definitionServiceBase = new DefinitionServiceBase(definitionService, context);
ProcessServiceBase processServiceBase = new ProcessServiceBase(processService, definitionService, runtimeDataService, context);
UserTaskServiceBase userTaskServiceBase = new UserTaskServiceBase(userTaskService, context);
RuntimeDataServiceBase runtimeDataServiceBase = new RuntimeDataServiceBase(runtimeDataService, advanceRuntimeDataService, context);
ExecutorServiceBase executorServiceBase = new ExecutorServiceBase(executorService, context);
QueryDataServiceBase queryDataServiceBase = new QueryDataServiceBase(queryService, context);
DocumentServiceBase documentServiceBase = new DocumentServiceBase(context);
ProcessAdminServiceBase processAdminServiceBase = new ProcessAdminServiceBase(processInstanceMigrationService, processInstanceAdminService, runtimeDataService, context);
UserTaskAdminServiceBase userTaskAdminServiceBase = new UserTaskAdminServiceBase(userTaskAdminService, context);
components.add(new ProcessResource(processServiceBase, runtimeDataServiceBase, context));
components.add(new RuntimeDataResource(runtimeDataServiceBase, context));
components.add(new DefinitionResource(definitionServiceBase, context));
components.add(new UserTaskResource(userTaskServiceBase, runtimeDataServiceBase, context));
components.add(new ExecutorResource(executorServiceBase, context));
components.add(new QueryDataResource(queryDataServiceBase, context));
components.add(new DocumentResource(documentServiceBase, context));
components.add(new ProcessAdminResource(processAdminServiceBase, context));
components.add(new UserTaskAdminResource(userTaskAdminServiceBase, context));
return components;
}
use of org.jbpm.services.api.AdvanceRuntimeDataService in project businessautomation-cop by redhat-cop.
the class CustomJbpmKieServerAppComponentService method getAppComponents.
public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
// skip calls from other than owning extension
if (!OWNER_EXTENSION.equals(extension)) {
return Collections.emptyList();
}
logger.debug("Creating custom kie server extension CustomJbpmKieServerAppComponentService");
RuntimeDataService runtimeDataService = null;
AdvanceRuntimeDataService advanceRuntimeDataService = null;
KieServerRegistry context = null;
for (Object object : services) {
if (RuntimeDataService.class.isAssignableFrom(object.getClass())) {
runtimeDataService = (RuntimeDataService) object;
continue;
} else if (AdvanceRuntimeDataService.class.isAssignableFrom(object.getClass())) {
advanceRuntimeDataService = (AdvanceRuntimeDataService) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
}
}
List<Object> components = new ArrayList<Object>(1);
if (SupportedTransports.REST.equals(type)) {
RuntimeDataServiceBase runtimeDataServiceBase = new RuntimeDataServiceBase(runtimeDataService, advanceRuntimeDataService, context);
components.add(new CustomResource(runtimeDataServiceBase, context));
}
return components;
}
Aggregations