use of org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService in project droolsjbpm-integration by kiegroup.
the class CaseKieServerExtension method configureServices.
protected void configureServices(KieServerImpl kieServer, KieServerRegistry registry) {
KieServerExtension jbpmExtension = registry.getServerExtension("jBPM");
List<Object> jbpmServices = jbpmExtension.getServices();
RuntimeDataService runtimeDataService = null;
ProcessService processService = null;
DeploymentService deploymentService = null;
ProcessInstanceMigrationService processInstanceMigrationService = null;
for (Object object : jbpmServices) {
// in case given service is null (meaning was not configured) continue with next one
if (object == null) {
continue;
}
if (RuntimeDataService.class.isAssignableFrom(object.getClass())) {
runtimeDataService = (RuntimeDataService) object;
continue;
} else if (ProcessService.class.isAssignableFrom(object.getClass())) {
processService = (ProcessService) object;
continue;
} else if (DeploymentService.class.isAssignableFrom(object.getClass())) {
deploymentService = (DeploymentService) object;
continue;
} else if (ProcessInstanceMigrationService.class.isAssignableFrom(object.getClass())) {
processInstanceMigrationService = (ProcessInstanceMigrationService) object;
continue;
}
}
CaseIdGenerator caseIdGenerator = getCaseIdGenerator();
EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(persistenceUnitName);
// build case runtime data service
caseRuntimeDataService = new CaseRuntimeDataServiceImpl();
((CaseRuntimeDataServiceImpl) caseRuntimeDataService).setCaseIdGenerator(caseIdGenerator);
((CaseRuntimeDataServiceImpl) caseRuntimeDataService).setRuntimeDataService(runtimeDataService);
((CaseRuntimeDataServiceImpl) caseRuntimeDataService).setCommandService(new TransactionalCommandService(EntityManagerFactoryManager.get().getOrCreate(persistenceUnitName)));
((CaseRuntimeDataServiceImpl) caseRuntimeDataService).setIdentityProvider(registry.getIdentityProvider());
// build case service
CaseServiceImpl caseService = new CaseServiceImpl();
((CaseServiceImpl) caseService).setCaseIdGenerator(caseIdGenerator);
((CaseServiceImpl) caseService).setCaseRuntimeDataService(caseRuntimeDataService);
((CaseServiceImpl) caseService).setProcessService(processService);
((CaseServiceImpl) caseService).setDeploymentService(deploymentService);
((CaseServiceImpl) caseService).setRuntimeDataService(runtimeDataService);
((CaseServiceImpl) caseService).setCommandService(new TransactionalCommandService(emf));
((CaseServiceImpl) caseService).setAuthorizationManager(new AuthorizationManagerImpl(registry.getIdentityProvider(), new TransactionalCommandService(EntityManagerFactoryManager.get().getOrCreate(persistenceUnitName))));
((CaseServiceImpl) caseService).setIdentityProvider(registry.getIdentityProvider());
// build case configuration on deployment listener
CaseConfigurationDeploymentListener configurationListener = new CaseConfigurationDeploymentListener(registry.getIdentityProvider());
// configure case mgmt services as listeners
((KModuleDeploymentService) deploymentService).addListener((CaseRuntimeDataServiceImpl) caseRuntimeDataService);
((KModuleDeploymentService) deploymentService).addListener(configurationListener);
CaseInstanceMigrationService caseInstanceMigrationService = new CaseInstanceMigrationServiceImpl();
((CaseInstanceMigrationServiceImpl) caseInstanceMigrationService).setCaseRuntimeDataService(caseRuntimeDataService);
((CaseInstanceMigrationServiceImpl) caseInstanceMigrationService).setCommandService(new TransactionalCommandService(EntityManagerFactoryManager.get().getOrCreate(persistenceUnitName)));
((CaseInstanceMigrationServiceImpl) caseInstanceMigrationService).setProcessInstanceMigrationService(processInstanceMigrationService);
((CaseInstanceMigrationServiceImpl) caseInstanceMigrationService).setProcessService(processService);
advanceCaseRuntimeDataService = new AdvanceCaseRuntimeDataServiceImpl();
((AdvanceCaseRuntimeDataServiceImpl) advanceCaseRuntimeDataService).setEmf(emf);
((AdvanceCaseRuntimeDataServiceImpl) advanceCaseRuntimeDataService).setCommandService(new TransactionalCommandService(emf));
this.caseManagementServiceBase = new CaseManagementServiceBase(caseService, caseRuntimeDataService, registry);
this.caseManagementRuntimeDataService = new CaseManagementRuntimeDataServiceBase(caseRuntimeDataService, advanceCaseRuntimeDataService, registry);
this.caseAdminServiceBase = new CaseAdminServiceBase(caseInstanceMigrationService, registry);
}
Aggregations