Package org.camunda.bpm.engine

Examples of org.camunda.bpm.engine.ProcessEngine


  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);
    }

    // delete deployment if we were able to create one AND if 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);
      }
    }

  }
View Full Code Here


  }

  protected ProcessEngine getProcessEngine(final PlatformServiceContainer serviceContainer) {
    String processEngineName = processArchive.getProcessEngineName();
    if(processEngineName != null) {
      ProcessEngine processEngine = serviceContainer.getServiceValue(ServiceTypes.PROCESS_ENGINE, processEngineName);
      ensureNotNull("Cannot deploy process archive '" + processArchive.getName() + "' to process engine '" + processEngineName + "' no such process engine exists", "processEngine", processEngine);
      return processEngine;

    } else {
      ProcessEngine processEngine = serviceContainer.getServiceValue(ServiceTypes.PROCESS_ENGINE, "default");
      ensureNotNull("Cannot deploy process archive '" + processArchive.getName() + "' to default process: no such process engine exists", "processEngine", processEngine);
      return processEngine;
    }
  }
View Full Code Here

    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();

    final Map<String, DeployedProcessArchive> processArchiveDeploymentMap = deployedProcessApplication.getProcessArchiveDeploymentMap();
    final DeployedProcessArchive deployedProcessArchive = processArchiveDeploymentMap.get(processArchive.getName());
    final ProcessEngine processEngine = serviceContainer.getServiceValue(ServiceTypes.PROCESS_ENGINE, processEngineName);

    // unregrister with the process engine.
    processEngine.getManagementService().unregisterProcessApplication(deployedProcessArchive.getAllDeploymentIds(), true);

    // delete the deployment if not disabled
    if (PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DELETE_UPON_UNDEPLOY, false)) {
      if (processEngine != null) {
        // always cascade & skip custom listeners
        deleteDeployment(deployedProcessArchive.getPrimaryDeploymentId(), processEngine.getRepositoryService());
      }
    }

  }
View Full Code Here

      thread.interrupt();
    }
  }

  public static ProcessEngine getProcessEngine(String configurationResource) {
    ProcessEngine processEngine = processEngines.get(configurationResource);
    if (processEngine==null) {
      log.fine("==== BUILDING PROCESS ENGINE ========================================================================");
      processEngine = ProcessEngineConfiguration
        .createProcessEngineConfigurationFromResource(configurationResource)
        .buildProcessEngine();
View Full Code Here

    StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
    standaloneProcessEngineConfiguration.setProcessEngineName(getClass().getName() + "-engine1");
    standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:jobexecutor-test-engine");
    standaloneProcessEngineConfiguration.setJobExecutorActivate(false);
    standaloneProcessEngineConfiguration.setJobExecutor(jobExecutor);
    ProcessEngine engine = standaloneProcessEngineConfiguration.buildProcessEngine();
   
    jobExecutor.registerProcessEngine((ProcessEngineImpl) engine);
       
       
    engine.getRepositoryService().createDeployment()
      .addClasspathResource(PROCESS_RESOURCE)
      .deploy();
   
    jobExecutor.shutdown();
   
    engine.getRuntimeService()
      .startProcessInstanceByKey("intermediateTimerEventExample");
   
    Assert.assertEquals(1, engine.getManagementService().createJobQuery().count());
   
    try {
      Calendar calendar = Calendar.getInstance();
      calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6);
      ClockUtil.setCurrentTime(calendar.getTime());
      jobExecutor.start();
      waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine.getManagementService(), true);
     
      Assert.assertEquals(0, engine.getManagementService().createJobQuery().count());
     
    }finally {
      ClockUtil.reset();
      engine.close();
    }
   
  }
View Full Code Here

    StandaloneProcessEngineConfiguration engineConfiguration1 = new StandaloneInMemProcessEngineConfiguration();
    engineConfiguration1.setProcessEngineName(getClass().getName() + "-engine1");
    engineConfiguration1.setJdbcUrl("jdbc:h2:mem:activiti1");
    engineConfiguration1.setJobExecutorActivate(false);
    engineConfiguration1.setJobExecutor(jobExecutor);
    ProcessEngine engine1 = engineConfiguration1.buildProcessEngine();
   
    // and a second one
    StandaloneProcessEngineConfiguration engineConfiguration2 = new StandaloneInMemProcessEngineConfiguration();
    engineConfiguration2.setProcessEngineName(getClass().getName() + "engine2");
    engineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti2");
    engineConfiguration2.setJobExecutorActivate(false);
    engineConfiguration1.setJobExecutor(jobExecutor);
    ProcessEngine engine2 = engineConfiguration2.buildProcessEngine();
              
    jobExecutor.registerProcessEngine((ProcessEngineImpl) engine1);
    jobExecutor.registerProcessEngine((ProcessEngineImpl) engine2);
   
    // stop the acquisition
    jobExecutor.shutdown();
   
    // deploy the processes
   
    engine1.getRepositoryService().createDeployment()
      .addClasspathResource(PROCESS_RESOURCE)
      .deploy();
   
    engine2.getRepositoryService().createDeployment()
     .addClasspathResource(PROCESS_RESOURCE)
     .deploy();
   
    // start one instance for each engine:
       
    engine1.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
    engine2.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
   
    Assert.assertEquals(1, engine1.getManagementService().createJobQuery().count());
    Assert.assertEquals(1, engine2.getManagementService().createJobQuery().count());
   
    try {
      Calendar calendar = Calendar.getInstance();
      calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6);
      ClockUtil.setCurrentTime(calendar.getTime());
     
      jobExecutor.start();
      // assert task completed for the first engine
      waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine1.getManagementService(), true);
     
      jobExecutor.start();
      // assert task completed for the second engine
      waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine2.getManagementService(), true);
     
      Assert.assertEquals(0, engine1.getManagementService().createJobQuery().count());
      Assert.assertEquals(0, engine2.getManagementService().createJobQuery().count());
     
    }finally {
      ClockUtil.reset();
      engine1.close();
      engine2.close();
    }   
  }
View Full Code Here

    StandaloneProcessEngineConfiguration engineConfiguration1 = new StandaloneInMemProcessEngineConfiguration();
    engineConfiguration1.setProcessEngineName(getClass().getName() + "-engine1");
    engineConfiguration1.setJdbcUrl("jdbc:h2:mem:activiti1");
    engineConfiguration1.setJobExecutorActivate(false);
    engineConfiguration1.setJobExecutor(jobExecutor);
    ProcessEngine engine1 = engineConfiguration1.buildProcessEngine();
   
    // and a second one
    StandaloneProcessEngineConfiguration engineConfiguration2 = new StandaloneInMemProcessEngineConfiguration();
    engineConfiguration2.setProcessEngineName(getClass().getName() + "engine2");
    engineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti2");
    engineConfiguration2.setJobExecutorActivate(false);
    engineConfiguration1.setJobExecutor(jobExecutor);
    ProcessEngine engine2 = engineConfiguration2.buildProcessEngine();
              
    jobExecutor.registerProcessEngine((ProcessEngineImpl) engine1);
    jobExecutor.registerProcessEngine((ProcessEngineImpl) engine2);
   
    // stop the acquisition
    jobExecutor.shutdown();
       
    // deploy the processes
   
    engine1.getRepositoryService().createDeployment()
      .addClasspathResource(PROCESS_RESOURCE)
      .deploy();
   
    engine2.getRepositoryService().createDeployment()
     .addClasspathResource(PROCESS_RESOURCE)
     .deploy();
   
    try {
      // start one instance for each engine:
     
      engine1.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
      engine2.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
     
      Calendar calendar = Calendar.getInstance();
      calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6);
      ClockUtil.setCurrentTime(calendar.getTime());
     
      Assert.assertEquals(1, engine1.getManagementService().createJobQuery().count());
      Assert.assertEquals(1, engine2.getManagementService().createJobQuery().count());
         
      // assert task completed for the first engine
      jobExecutor.start();
      waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine1.getManagementService(), false);
     
      // assert task completed for the second engine
      jobExecutor.start();
      waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine2.getManagementService(), false);
     
      Thread.sleep(2000);
     
      Assert.assertFalse(((SequentialJobAcquisitionRunnable) jobExecutor.getAcquireJobsRunnable()).isJobAdded());
     
      Assert.assertEquals(0, engine1.getManagementService().createJobQuery().count());
      Assert.assertEquals(0, engine2.getManagementService().createJobQuery().count());
     
     
    }finally {
     
      ClockUtil.reset();
      engine1.close();
      engine2.close();
    }   
  }
View Full Code Here

            .setJobExecutorDeploymentAware(true);
      } else {
        throw ex;
      }
    }
    ProcessEngine otherEngine = otherProcessEngineConfiguration.buildProcessEngine();

    // 2. deploy again
    RepositoryService otherRepositoryService = otherEngine.getRepositoryService();

    String deploymentId = otherRepositoryService.createDeployment()
      .addClasspathResource(resource)
      .deploy().getId();

    // 3. start instance (i.e. create job)
    ProcessDefinition newDefinition = otherRepositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
    otherEngine.getRuntimeService().startProcessInstanceById(newDefinition.getId());

    return deploymentId;
  }
View Full Code Here

    ManagedReference reference = null;
    try {

      // get process engine
      ProcessEngine processEngine = processEngineInjector.getValue();

      // get the process application component
      ProcessApplicationInterface processApplication = null;
      ComponentView componentView = paComponentViewInjector.getOptionalValue();
      if(componentView != null) {
        reference = componentView.createInstance();
        processApplication = (ProcessApplicationInterface) reference.getInstance();
      } else {
        processApplication = noViewProcessApplication.getValue();
      }

      // get the application name
      String processApplicationName = processApplication.getName();

      // build the deployment
      final RepositoryService repositoryService = processEngine.getRepositoryService();

      final ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.getReference());

      // enable duplicate filtering
      deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY, false));
View Full Code Here

    LOGGER.log(Level.INFO, builder.toString());
  }

  protected void performUndeployment() {

    final ProcessEngine processEngine = processEngineInjector.getValue();

    try {
      if(deployment != null) {
        // always unregister
        Set<String> deploymentIds = deployment.getProcessApplicationRegistration().getDeploymentIds();
        processEngine.getManagementService().unregisterProcessApplication(deploymentIds, true);
      }
    } catch(Exception e) {
      LOGGER.log(Level.SEVERE, "Exception while unregistering process application with the process engine.");

    }

    // delete the deployment only if requested in metadata
    if(deployment != null && PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DELETE_UPON_UNDEPLOY, false)) {
      try {
        LOGGER.info("Deleting cascade deployment with name '"+deployment.getName()+"/"+deployment.getId()+"'.");
        // always cascade & skip custom listeners
        processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true, true);

      } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Exception while deleting process engine deployment", e);

      }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.ProcessEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.