protected internal void Finished()
 {
     DeleteHistoryCleanupJob();
     _processEngine.Close();
     ProcessEngines.Unregister(_processEngine);
     _processEngine = null;
 }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void cleanUp()
        public virtual void cleanUp()
        {
            identityService.deleteTenant(TENANT_ONE);
            identityService.deleteTenant(TENANT_TWO);

            identityService.deleteGroup(GROUP_ONE);
            identityService.deleteGroup(GROUP_TWO);

            identityService.deleteUser(USER_ONE);
            identityService.deleteUser(USER_TWO);

            if (processEngine != null)
            {
                foreach (Tenant deleteTenant in processEngine.IdentityService.createTenantQuery().list())
                {
                    processEngine.IdentityService.deleteTenant(deleteTenant.Id);
                }
                foreach (Authorization authorization in processEngine.AuthorizationService.createAuthorizationQuery().list())
                {
                    processEngine.AuthorizationService.deleteAuthorization(authorization.Id);
                }

                processEngine.close();
                ProcessEngines.unregister(processEngine);
                processEngine = null;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Must return an iterator of registered process engines
 ///     that is independent of concurrent modifications
 ///     to the underlying data structure of engines.
 /// </summary>
 public virtual IEnumerator <ProcessEngineImpl> EngineIterator()
 {
     // Todo: Concurrent并发安全
     // a CopyOnWriteArrayList's iterator is safe in the presence
     // of modifications
     return(ProcessEngines.GetEnumerator());
 }
Exemplo n.º 4
0
 protected internal override void finished(Description description)
 {
     deleteHistoryCleanupJob();
     processEngine.close();
     ProcessEngines.unregister(processEngine);
     processEngine = null;
 }
Exemplo n.º 5
0
 public virtual void ExecuteJobs(IList <string> jobIds)
 {
     if (ProcessEngines.Count > 0)
     {
         ExecuteJobs(jobIds, ProcessEngines.ElementAt(0));
     }
 }
Exemplo n.º 6
0
        public ProcessEngineImpl(ProcessEngineConfigurationImpl processEngineConfiguration)
        {
            this.processEngineConfiguration = processEngineConfiguration;
            Name = processEngineConfiguration.ProcessEngineName;

            RepositoryService    = processEngineConfiguration.RepositoryService;
            RuntimeService       = processEngineConfiguration.RuntimeService;
            HistoryService       = processEngineConfiguration.HistoryService;
            IdentityService      = processEngineConfiguration.IdentityService;
            TaskService          = processEngineConfiguration.TaskService;
            FormService          = processEngineConfiguration.FormService;
            ManagementService    = processEngineConfiguration.ManagementService;
            AuthorizationService = processEngineConfiguration.AuthorizationService;
            //this.caseService = processEngineConfiguration.CaseService;
            FilterService       = processEngineConfiguration.FilterService;
            ExternalTaskService = processEngineConfiguration.ExternalTaskService;
            DecisionService     = processEngineConfiguration.DecisionService;

            DatabaseSchemaUpdate            = processEngineConfiguration.DatabaseSchemaUpdate;
            JobExecutor                     = processEngineConfiguration.JobExecutor;
            commandExecutor                 = processEngineConfiguration.CommandExecutorTxRequired;
            CommandExecutorSchemaOperations = processEngineConfiguration.CommandExecutorSchemaOperations;
            //SessionFactories = processEngineConfiguration.SessionFactories;
            HistoryLevel = processEngineConfiguration.HistoryLevel;
            TransactionContextFactory = processEngineConfiguration.TransactionContextFactory;
            Log.LogDebug("使用的TransactionContextFactory:", TransactionContextFactory.GetType().Name.ToString());
            //TODO 数据库初始化入口
            //ExecuteSchemaOperations();

            if (ReferenceEquals(Name, null))
            {
                Name = ProcessEngines.NameDefault;
                Log.ProcessEngineCreated(ProcessEngines.NameDefault);
            }
            else
            {
                Log.ProcessEngineCreated(Name);
            }

            ProcessEngines.RegisterProcessEngine(this);

            if (JobExecutor != null)
            {
                JobExecutor.RegisterProcessEngine(this);
            }

            if (processEngineConfiguration.MetricsEnabled)
            {
                var reporterId        = processEngineConfiguration.MetricsReporterIdProvider.ProvideId(this);
                var dbMetricsReporter = processEngineConfiguration.DbMetricsReporter;
                dbMetricsReporter.ReporterId = reporterId;

                if (processEngineConfiguration.DbMetricsReporterActivate)
                {
                    dbMetricsReporter.Start();
                }
            }
        }
Exemplo n.º 7
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.identityService      = processEngineConfiguration.IdentityService;
            this.taskService          = processEngineConfiguration.TaskService;
            this.formService          = processEngineConfiguration.FormService;
            this.managementService    = processEngineConfiguration.ManagementService;
            this.authorizationService = processEngineConfiguration.AuthorizationService;
            this.caseService          = processEngineConfiguration.CaseService;
            this.filterService        = processEngineConfiguration.FilterService;
            this.externalTaskService  = processEngineConfiguration.ExternalTaskService;
            this.decisionService      = processEngineConfiguration.DecisionService;

            this.databaseSchemaUpdate       = processEngineConfiguration.DatabaseSchemaUpdate;
            this.jobExecutor                = processEngineConfiguration.JobExecutor;
            this.commandExecutor            = processEngineConfiguration.CommandExecutorTxRequired;
            commandExecutorSchemaOperations = processEngineConfiguration.CommandExecutorSchemaOperations;
            this.sessionFactories           = processEngineConfiguration.SessionFactories;
            this.historyLevel               = processEngineConfiguration.HistoryLevel;
            this.transactionContextFactory  = processEngineConfiguration.TransactionContextFactory;

            executeSchemaOperations();

            if (string.ReferenceEquals(name, null))
            {
                LOG.processEngineCreated(ProcessEngines.NAME_DEFAULT);
            }
            else
            {
                LOG.processEngineCreated(name);
            }

            ProcessEngines.registerProcessEngine(this);

            if ((jobExecutor != null))
            {
                // register process engine with Job Executor
                jobExecutor.registerProcessEngine(this);
            }

            if (processEngineConfiguration.MetricsEnabled)
            {
                string            reporterId        = processEngineConfiguration.MetricsReporterIdProvider.provideId(this);
                DbMetricsReporter dbMetricsReporter = processEngineConfiguration.DbMetricsReporter;
                dbMetricsReporter.ReporterId = reporterId;

                if (processEngineConfiguration.DbMetricsReporterActivate)
                {
                    dbMetricsReporter.start();
                }
            }
        }
Exemplo n.º 8
0
 protected internal override void closeDownProcessEngine()
 {
     base.closeDownProcessEngine();
     if (otherProcessEngine != null)
     {
         otherProcessEngine.close();
         ProcessEngines.unregister(otherProcessEngine);
         otherProcessEngine = null;
     }
 }
 protected internal virtual void closeDownProcessEngine()
 {
     CloseDownProcessEngine();
     if (OtherProcessEngine != null)
     {
         OtherProcessEngine.Close();
         ProcessEngines.Unregister(OtherProcessEngine);
         OtherProcessEngine = null;
     }
 }
Exemplo n.º 10
0
        public virtual void CloseProcessEngines()
        {
            var iterator = _createdProcessEngines.GetEnumerator();

            while (iterator.MoveNext())
            {
                var processEngine = iterator.Current;
                processEngine.Close();
                ProcessEngines.Unregister(processEngine);
                //JAVA TO C# CONVERTER TODO Resources.Task: .NET enumerators are read-only:
                //iterator.Remove();
            }
        }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void closeProcessEngines()
        public virtual void closeProcessEngines()
        {
            IEnumerator <ProcessEngine> iterator = createdProcessEngines.GetEnumerator();

            while (iterator.MoveNext())
            {
                ProcessEngine processEngine = iterator.Current;
                processEngine.close();
                ProcessEngines.unregister(processEngine);
//JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only:
                iterator.remove();
            }
        }
Exemplo n.º 12
0
        public virtual void UnregisterProcessEngine(ProcessEngineImpl processEngine)
        {
            lock (this)
            {
                ProcessEngines.Remove(processEngine);

                // if we unregister the last process engine, auto-shutdown the jobexecutor
                if (ProcessEngines.Count == 0 && IsActive)
                {
                    Shutdown();
                }
            }
        }
Exemplo n.º 13
0
        public virtual void RegisterProcessEngine(ProcessEngineImpl processEngine)
        {
            lock (this)
            {
                ProcessEngines.Add(processEngine);

                // when we register the first process engine, start the jobexecutor
                if ((ProcessEngines.Count == 1) && AutoActivate)
                {
                    Start();
                }
            }
        }
Exemplo n.º 14
0
        protected internal override void closeDownProcessEngine()
        {
            base.closeDownProcessEngine();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.ProcessEngine otherProcessEngine = org.camunda.bpm.engine.ProcessEngines.getProcessEngine(PROCESS_ENGINE_NAME);
            ProcessEngine otherProcessEngine = ProcessEngines.getProcessEngine(PROCESS_ENGINE_NAME);

            if (otherProcessEngine != null)
            {
                ((ProcessEngineConfigurationImpl)otherProcessEngine.ProcessEngineConfiguration).CommandExecutorTxRequired.execute(new CommandAnonymousInnerClass(this, otherProcessEngine));

                otherProcessEngine.close();
                ProcessEngines.unregister(otherProcessEngine);
            }
        }
Exemplo n.º 15
0
        public virtual void TestProcessEngineInfo()
        {
            var processEngineInfos = ProcessEngines.ProcessEngineInfos;

            Assert.AreEqual(1, processEngineInfos.Count);

            var processEngineInfo = processEngineInfos[0];

            Assert.IsNull(processEngineInfo.Exception);
            Assert.NotNull(processEngineInfo.Name);
            Assert.NotNull(processEngineInfo.ResourceUrl);

            var processEngine = ProcessEngines.GetProcessEngine(ProcessEngines.NameDefault);

            Assert.NotNull(processEngine);
        }
Exemplo n.º 16
0
        public virtual void testProcessEngineInfo()
        {
            IList <ProcessEngineInfo> processEngineInfos = ProcessEngines.ProcessEngineInfos;

            assertEquals(1, processEngineInfos.Count);

            ProcessEngineInfo processEngineInfo = processEngineInfos[0];

            assertNull(processEngineInfo.Exception);
            assertNotNull(processEngineInfo.Name);
            assertNotNull(processEngineInfo.ResourceUrl);

            ProcessEngine processEngine = ProcessEngines.getProcessEngine(ProcessEngines.NAME_DEFAULT);

            assertNotNull(processEngine);
        }
Exemplo n.º 17
0
        public virtual void Close()
        {
            ProcessEngines.Unregister(this);

            if (processEngineConfiguration.MetricsEnabled)
            {
                processEngineConfiguration.DbMetricsReporter.Stop();
            }

            if (JobExecutor != null)
            {
                JobExecutor.UnregisterProcessEngine(this);
            }

            CommandExecutorSchemaOperations.Execute(new SchemaOperationProcessEngineClose());

            //processEngineConfiguration.Close();

            Log.ProcessEngineClosed(Name);
        }
Exemplo n.º 18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testConsecutiveEngineBootstrapHistoryCleanupJobReconfiguration()
        public virtual void testConsecutiveEngineBootstrapHistoryCleanupJobReconfiguration()
        {
            // given
            // create history cleanup job
            ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/history/batchwindow.camunda.cfg.xml").buildProcessEngine().close();

            // when
            // suspend history cleanup job
            ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/history/no-batchwindow.camunda.cfg.xml").buildProcessEngine().close();

            // then
            // reconfigure history cleanup job
            ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/history/batchwindow.camunda.cfg.xml");

            processEngineConfiguration.ProcessEngineName = ENGINE_NAME;
            ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

            assertNotNull(ProcessEngines.getProcessEngine(ENGINE_NAME));

            closeProcessEngine(processEngine);
        }
Exemplo n.º 19
0
        public virtual void close()
        {
            ProcessEngines.unregister(this);

            if (processEngineConfiguration.MetricsEnabled)
            {
                processEngineConfiguration.DbMetricsReporter.stop();
            }

            if ((jobExecutor != null))
            {
                // unregister process engine with Job Executor
                jobExecutor.unregisterProcessEngine(this);
            }

            commandExecutorSchemaOperations.execute(new SchemaOperationProcessEngineClose());

            processEngineConfiguration.close();

            LOG.processEngineClosed(name);
        }
Exemplo n.º 20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Produces @Named @ApplicationScoped public org.camunda.bpm.engine.ProcessEngine processEngine()
        public virtual ProcessEngine processEngine()
        {
            ProcessEngine processEngine = BpmPlatform.ProcessEngineService.DefaultProcessEngine;

            if (processEngine != null)
            {
                return(processEngine);
            }
            else
            {
                IList <ProcessEngine> processEngines = BpmPlatform.ProcessEngineService.ProcessEngines;
                if (processEngines != null && processEngines.Count == 1)
                {
                    return(processEngines[0]);
                }
                else
                {
                    return(ProcessEngines.getDefaultProcessEngine(false));
                }
            }
        }
Exemplo n.º 21
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void setUp() throws Exception
        protected internal virtual void setUp()
        {
            base.setUp();
            ProcessEngines.destroy();
            ProcessEngines.init();
        }
Exemplo n.º 22
0
 public virtual bool HasRegisteredEngine(ProcessEngineImpl engine)
 {
     return(ProcessEngines.Contains(engine));
 }
Exemplo n.º 23
0
 public virtual ProcessEngine getProcessEngine(string name)
 {
     return(ProcessEngines.getProcessEngine(name));
 }
Exemplo n.º 24
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void execute() throws org.apache.tools.ant.BuildException
        public virtual void execute()
        {
            IList <File> files = new List <File>();

            if (file != null)
            {
                files.Add(file);
            }
            if (fileSets != null)
            {
                foreach (FileSet fileSet in fileSets)
                {
                    DirectoryScanner directoryScanner  = fileSet.getDirectoryScanner(Project);
                    File             baseDir           = directoryScanner.Basedir;
                    string[]         includedFiles     = directoryScanner.IncludedFiles;
                    string[]         excludedFiles     = directoryScanner.ExcludedFiles;
                    IList <string>   excludedFilesList = Arrays.asList(excludedFiles);
                    foreach (string includedFile in includedFiles)
                    {
                        if (!excludedFilesList.Contains(includedFile))
                        {
                            files.Add(new File(baseDir, includedFile));
                        }
                    }
                }
            }

            Thread      currentThread       = Thread.CurrentThread;
            ClassLoader originalClassLoader = currentThread.ContextClassLoader;

            currentThread.ContextClassLoader = typeof(DeployBarTask).ClassLoader;

            LogUtil.readJavaUtilLoggingConfigFromClasspath();

            try
            {
                log("Initializing process engine " + processEngineName);
                ProcessEngines.init();
                ProcessEngine processEngine = ProcessEngines.getProcessEngine(processEngineName);
                if (processEngine == null)
                {
                    IList <ProcessEngineInfo> processEngineInfos = ProcessEngines.ProcessEngineInfos;
                    if (processEngineInfos != null && processEngineInfos.Count > 0)
                    {
                        // Since no engine with the given name is found, we can't be 100% sure which ProcessEngineInfo
                        // is causing the error. We should show ALL errors and process engine names / resource URL's.
                        string message = getErrorMessage(processEngineInfos, processEngineName);
                        throw new ProcessEngineException(message);
                    }
                    else
                    {
                        throw new ProcessEngineException("Could not find a process engine with name '" + processEngineName + "', no engines found. " + "Make sure an engine configuration is present on the classpath");
                    }
                }
                RepositoryService repositoryService = processEngine.RepositoryService;

                log("Starting to deploy " + files.Count + " files");
                foreach (File file in files)
                {
                    string path = file.AbsolutePath;
                    log("Handling file " + path);
                    try
                    {
                        FileStream inputStream = new FileStream(file, FileMode.Open, FileAccess.Read);
                        try
                        {
                            log("deploying bar " + path);
                            repositoryService.createDeployment().name(file.Name).addZipInputStream(new ZipInputStream(inputStream)).deploy();
                        }
                        finally
                        {
                            IoUtil.closeSilently(inputStream);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new BuildException("couldn't deploy bar " + path + ": " + e.Message, e);
                    }
                }
            }
            finally
            {
                currentThread.ContextClassLoader = originalClassLoader;
            }
        }
Exemplo n.º 25
0
 /// <summary>
 ///     <para>
 ///         Creates the job executor and registers the given process engine
 ///         with it.
 ///     </para>
 ///     <para>
 ///         Use this constructor if the process engine is not registered
 ///         with the job executor when the process engine is bootstrapped.
 ///     </para>
 ///     <para>
 ///         Note: this is a hack since it enables to use multiple job executors with
 ///         the same engine which is not a supported feature (and for example clashes with
 ///         processEngineConfiguration#getJobExecutor)
 ///     </para>
 /// </summary>
 public ControllableJobExecutor(ProcessEngineImpl processEngine) : this()
 {
     ProcessEngines.Add(processEngine);
 }
Exemplo n.º 26
0
 protected internal virtual void SetUp()
 {
     //base.SetUp();
     ProcessEngines.Destroy();
     ProcessEngines.Init();
 }
Exemplo n.º 27
0
 protected internal virtual void TearDown()
 {
     ProcessEngines.Destroy();
     //base.TearDown();
 }
Exemplo n.º 28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void tearDown() throws Exception
        protected internal virtual void tearDown()
        {
            ProcessEngines.destroy();
            base.tearDown();
        }