예제 #1
0
        public ProcessEngineImpl(ProcessEngineConfigurationImpl processEngineConfiguration)
        {
            this.processEngineConfiguration = processEngineConfiguration;
            this.name = processEngineConfiguration.ProcessEngineName;
            this.repositoryService         = processEngineConfiguration.RepositoryService;
            this.runtimeService            = processEngineConfiguration.RuntimeService;
            this.historicDataService       = processEngineConfiguration.HistoryService;
            this.taskService               = processEngineConfiguration.TaskService;
            this.managementService         = processEngineConfiguration.ManagementService;
            this.dynamicBpmnService        = processEngineConfiguration.DynamicBpmnService;
            this.asyncExecutor             = processEngineConfiguration.AsyncExecutor;
            this.commandExecutor           = processEngineConfiguration.CommandExecutor;
            this.sessionFactories          = processEngineConfiguration.SessionFactories;
            this.transactionContextFactory = processEngineConfiguration.TransactionContextFactory;

            if (processEngineConfiguration.UsingRelationalDatabase && processEngineConfiguration.DatabaseSchemaUpdate is object)
            {
                commandExecutor.Execute(processEngineConfiguration.SchemaCommandConfig, new SchemaOperationsProcessEngineBuild());
            }

            if (name is null)
            {
                log.LogInformation("default activiti ProcessEngine created");
            }
            else
            {
                log.LogInformation($"ProcessEngine {name} created");
            }

            ProcessEngineFactory.RegisterProcessEngine(this);

            if (asyncExecutor != null && asyncExecutor.AutoActivate)
            {
                asyncExecutor.Start();
            }

            if (processEngineConfiguration.ProcessEngineLifecycleListener != null)
            {
                processEngineConfiguration.ProcessEngineLifecycleListener.OnProcessEngineBuilt(this);
            }

            processEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateGlobalEvent(ActivitiEventType.ENGINE_CREATED));
        }
예제 #2
0
        public static IProcessEngine UseProcessEngine(this IServiceProvider serviceProvider, IApplicationLifetime applicationLifetime, string processEngineName)
        {
            ProcessEngineServiceProvider.ServiceProvider = serviceProvider;

            if (string.IsNullOrWhiteSpace(processEngineName))
            {
                return(serviceProvider.GetService <IProcessEngine>());
            }

            ProcessEngineConfiguration processEngineConfig = serviceProvider.GetService <ProcessEngineConfiguration>();

            processEngineConfig.ProcessEngineName = processEngineName;

            IProcessEngine engine = processEngineConfig.BuildProcessEngine();

            ProcessEngineFactory.RegisterProcessEngine(engine);

            return(engine);
        }