Search in sources :

Example 26 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class DeployProcessArchiveStep method cancelOperationStep.

@Override
public void cancelOperationStep(DeploymentOperation operationContext) {
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    ProcessEngine processEngine = getProcessEngine(serviceContainer);
    // if a registration was performed, remove it.
    if (deployment != null && deployment.getProcessApplicationRegistration() != null) {
        processEngine.getManagementService().unregisterProcessApplication(deployment.getProcessApplicationRegistration().getDeploymentIds(), true);
    }
    // isDeleteUponUndeploy is set.
    if (deployment != null && PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DELETE_UPON_UNDEPLOY, false)) {
        if (processEngine != null) {
            processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true);
        }
    }
}
Also used : PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 27 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class DeployBarTask method execute.

public void execute() throws BuildException {
    List<File> files = new ArrayList<File>();
    if (file != null) {
        files.add(file);
    }
    if (fileSets != null) {
        for (FileSet fileSet : fileSets) {
            DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject());
            File baseDir = directoryScanner.getBasedir();
            String[] includedFiles = directoryScanner.getIncludedFiles();
            String[] excludedFiles = directoryScanner.getExcludedFiles();
            List<String> excludedFilesList = Arrays.asList(excludedFiles);
            for (String includedFile : includedFiles) {
                if (!excludedFilesList.contains(includedFile)) {
                    files.add(new File(baseDir, includedFile));
                }
            }
        }
    }
    Thread currentThread = Thread.currentThread();
    ClassLoader originalClassLoader = currentThread.getContextClassLoader();
    currentThread.setContextClassLoader(DeployBarTask.class.getClassLoader());
    LogUtil.readJavaUtilLoggingConfigFromClasspath();
    try {
        log("Initializing process engine " + processEngineName);
        ProcessEngines.init();
        ProcessEngine processEngine = ProcessEngines.getProcessEngine(processEngineName);
        if (processEngine == null) {
            List<ProcessEngineInfo> processEngineInfos = ProcessEngines.getProcessEngineInfos();
            if (processEngineInfos != null && processEngineInfos.size() > 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.getRepositoryService();
        log("Starting to deploy " + files.size() + " files");
        for (File file : files) {
            String path = file.getAbsolutePath();
            log("Handling file " + path);
            try {
                FileInputStream inputStream = new FileInputStream(file);
                try {
                    log("deploying bar " + path);
                    repositoryService.createDeployment().name(file.getName()).addZipInputStream(new ZipInputStream(inputStream)).deploy();
                } finally {
                    IoUtil.closeSilently(inputStream);
                }
            } catch (Exception e) {
                throw new BuildException("couldn't deploy bar " + path + ": " + e.getMessage(), e);
            }
        }
    } finally {
        currentThread.setContextClassLoader(originalClassLoader);
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) ArrayList(java.util.ArrayList) FileInputStream(java.io.FileInputStream) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) BuildException(org.apache.tools.ant.BuildException) ProcessEngineInfo(org.camunda.bpm.engine.ProcessEngineInfo) ZipInputStream(java.util.zip.ZipInputStream) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 28 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class EmbeddedProcessApplicationTest method testDeployAppWithoutProcesses.

public void testDeployAppWithoutProcesses() {
    registerProcessEngine();
    TestApplicationWithoutProcesses processApplication = new TestApplicationWithoutProcesses();
    processApplication.deploy();
    ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getDefaultProcessEngine();
    long deployments = processEngine.getRepositoryService().createDeploymentQuery().count();
    assertEquals(0, deployments);
    processApplication.undeploy();
}
Also used : ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 29 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class PlatformJobExecutorActivateTest method shouldAutoActivateIfNoPropertySet.

@Test
public void shouldAutoActivateIfNoPropertySet() {
    // given
    JobExecutorXmlImpl jobExecutorXml = defineJobExecutor();
    ProcessEngineXmlImpl processEngineXml = defineProcessEngine();
    BpmPlatformXmlImpl bpmPlatformXml = new BpmPlatformXmlImpl(jobExecutorXml, Collections.<ProcessEngineXml>singletonList(processEngineXml));
    // when
    deployPlatform(bpmPlatformXml);
    try {
        ProcessEngine processEngine = getProcessEngine(ENGINE_NAME);
        ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
        // then
        assertEquals(true, processEngineConfiguration.getJobExecutor().isActive());
    } finally {
        undeployPlatform();
    }
}
Also used : ProcessEngineXmlImpl(org.camunda.bpm.container.impl.metadata.ProcessEngineXmlImpl) JobExecutorXmlImpl(org.camunda.bpm.container.impl.metadata.JobExecutorXmlImpl) BpmPlatformXmlImpl(org.camunda.bpm.container.impl.metadata.BpmPlatformXmlImpl) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) Test(org.junit.Test)

Example 30 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class ForceCloseMybatisConnectionPoolTest method testForceCloseMybatisConnectionPoolFalse.

@Test
public void testForceCloseMybatisConnectionPoolFalse() {
    // given
    // that the process engine is configured with forceCloseMybatisConnectionPool = false
    ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:camunda-forceclose").setProcessEngineName("engine-forceclose").setForceCloseMybatisConnectionPool(false);
    ProcessEngine processEngine = configurationImpl.buildProcessEngine();
    PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource();
    PoolState state = pooledDataSource.getPoolState();
    int idleConnections = state.getIdleConnectionCount();
    // then
    // if the process engine is closed
    processEngine.close();
    // the idle connections are not closed
    Assert.assertEquals(state.getIdleConnectionCount(), idleConnections);
    pooledDataSource.forceCloseAll();
    Assert.assertTrue(state.getIdleConnectionCount() == 0);
}
Also used : PoolState(org.apache.ibatis.datasource.pooled.PoolState) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) PooledDataSource(org.apache.ibatis.datasource.pooled.PooledDataSource) Test(org.junit.Test)

Aggregations

ProcessEngine (org.camunda.bpm.engine.ProcessEngine)162 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)60 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)60 Task (org.camunda.bpm.engine.task.Task)52 Times (org.camunda.bpm.qa.upgrade.Times)52 Test (org.junit.Test)26 ExtendsScenario (org.camunda.bpm.qa.upgrade.ExtendsScenario)18 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)17 ArrayList (java.util.ArrayList)16 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)15 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)14 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)14 RepositoryService (org.camunda.bpm.engine.RepositoryService)13 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)7 StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 Job (org.camunda.bpm.engine.runtime.Job)5 Connection (java.sql.Connection)4 CaseService (org.camunda.bpm.engine.CaseService)4 StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)4