Java Code Examples for org.camunda.bpm.engine.ProcessEngine#close()

The following examples show how to use org.camunda.bpm.engine.ProcessEngine#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryCleanupOnEngineBootstrapTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void closeProcessEngine(ProcessEngine processEngine) {
  ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
  final HistoryService historyService = processEngine.getHistoryService();
  configuration.getCommandExecutorTxRequired().execute((Command<Void>) commandContext -> {

    List<Job> jobs = historyService.findHistoryCleanupJobs();
    for (Job job: jobs) {
      commandContext.getJobManager().deleteJob((JobEntity) job);
      commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(job.getId());
    }

    //cleanup "detached" historic job logs
    final List<HistoricJobLog> list = historyService.createHistoricJobLogQuery().list();
    for (HistoricJobLog jobLog: list) {
      commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobLog.getJobId());
    }

    commandContext.getMeterLogManager().deleteAll();

    return null;
  });

  processEngine.close();
}
 
Example 2
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  runner.setupScenarios(FailingIntermediateBoundaryTimerJobScenario.class);
  // batch deployment-awareness
  runner.setupScenarios(DeploymentAwareBatchesScenario.class);

  runner.setupScenarios(StartProcessIntanceWithInitialVariablesScenario.class);
  runner.setupScenarios(SetVariablesScenario.class);

  processEngine.close();
}
 
Example 3
Source File: ConcurrentProcessEngineJobExecutorHistoryCleanupJobTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
protected void closeDownProcessEngine() {
  super.closeDownProcessEngine();
  final ProcessEngine otherProcessEngine = ProcessEngines.getProcessEngine(PROCESS_ENGINE_NAME);
  if (otherProcessEngine != null) {

    ((ProcessEngineConfigurationImpl)otherProcessEngine.getProcessEngineConfiguration()).getCommandExecutorTxRequired().execute(new Command<Void>() {
      public Void execute(CommandContext commandContext) {

        List<Job> jobs = otherProcessEngine.getManagementService().createJobQuery().list();
        if (jobs.size() > 0) {
          assertEquals(1, jobs.size());
          String jobId = jobs.get(0).getId();
          commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
          commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
        }

        return null;
      }
    });

    otherProcessEngine.close();
    ProcessEngines.unregister(otherProcessEngine);
  }
}
 
Example 4
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  runner.setupScenarios(DeleteHistoricDecisionsBatchScenario.class);
  runner.setupScenarios(DeleteHistoricProcessInstancesBatchScenario.class);
  runner.setupScenarios(DeleteProcessInstancesBatchScenario.class);
  runner.setupScenarios(SetExternalTaskRetriesBatchScenario.class);
  runner.setupScenarios(SetJobRetriesBatchScenario.class);
  runner.setupScenarios(UpdateProcessInstanceSuspendStateBatchScenario.class);
  runner.setupScenarios(RestartProcessInstanceBatchScenario.class);
  runner.setupScenarios(TimerChangeProcessDefinitionScenario.class);
  runner.setupScenarios(TimerChangeJobDefinitionScenario.class);
  runner.setupScenarios(ModificationBatchScenario.class);
  runner.setupScenarios(ProcessInstanceModificationScenario.class);
  runner.setupScenarios(MigrationBatchScenario.class);
  runner.setupScenarios(TaskFilterScenario.class);
  runner.setupScenarios(TaskFilterVariablesScenario.class);
  runner.setupScenarios(TaskFilterPropertiesScenario.class);
  runner.setupScenarios(DeploymentDeployTimeScenario.class);
  runner.setupScenarios(JobTimestampsScenario.class);
  runner.setupScenarios(IncidentTimestampScenario.class);
  runner.setupScenarios(TaskCreateTimeScenario.class);
  runner.setupScenarios(ExternalTaskLockExpTimeScenario.class);
  runner.setupScenarios(EventSubscriptionCreateTimeScenario.class);
  runner.setupScenarios(MeterLogTimestampScenario.class);
  runner.setupScenarios(UserLockExpTimeScenario.class);
  runner.setupScenarios(CreateStandaloneTaskScenario.class);
  runner.setupScenarios(SetAssigneeProcessInstanceTaskScenario.class);
  runner.setupScenarios(CreateStandaloneTaskDeleteScenario.class);
  runner.setupScenarios(SuspendProcessDefinitionDeleteScenario.class);
  runner.setupScenarios(AuthorizationCheckProcessDefinitionScenario.class);
  runner.setupScenarios(NoAuthorizationCheckScenario.class);

  processEngine.close();
}
 
Example 5
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  // cmmn sentries
  runner.setupScenarios(SentryScenario.class);

  // compensation
  runner.setupScenarios(SingleActivityCompensationScenario.class);
  runner.setupScenarios(NestedCompensationScenario.class);
  runner.setupScenarios(SingleActivityConcurrentCompensationScenario.class);
  runner.setupScenarios(ParallelMultiInstanceCompensationScenario.class);
  runner.setupScenarios(SequentialMultiInstanceCompensationScenario.class);
  runner.setupScenarios(NestedMultiInstanceCompensationScenario.class);
  runner.setupScenarios(InterruptingEventSubProcessCompensationScenario.class);
  runner.setupScenarios(NonInterruptingEventSubProcessCompensationScenario.class);
  runner.setupScenarios(InterruptingEventSubProcessNestedCompensationScenario.class);

  // job
  runner.setupScenarios(JobMigrationScenario.class);

  // boundary events
  runner.setupScenarios(NonInterruptingBoundaryEventScenario.class);

  processEngine.close();
}
 
Example 6
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  // example scenario setup
  // runner.setupScenarios(ExampleScenario.class);

  processEngine.close();
}
 
Example 7
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  // example scenario setup
  // runner.setupScenarios(ExampleScenario.class);

  processEngine.close();
}
 
Example 8
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);
  // compensation
  runner.setupScenarios(DeployProcessWithoutIsExecutableAttributeScenario.class);

  processEngine.close();
}
 
Example 9
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  // compensation
  runner.setupScenarios(DeployUserWithoutSaltForPasswordHashingScenario.class);

  processEngine.close();
}
 
Example 10
Source File: ManagedProcessEngineFactoryImpl.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
@Override
public void deleted(String pid) {
  ProcessEngine engine = existingEngines.get(pid);
  if (engine != null) {
    engine.close();
    existingEngines.remove(pid);
    existingRegisteredEngines.get(pid).unregister();
    existingRegisteredEngines.remove(pid);
  }
}
 
Example 11
Source File: HistoryCleanupOnEngineBootstrapTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testDecreaseNumberOfHistoryCleanupJobs() {
  // given
  // create history cleanup job
  ProcessEngine engine = ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/history/history-cleanup-parallelism-default.camunda.cfg.xml")
    .buildProcessEngine();

  // assume
  ManagementService managementService = engine.getManagementService();
  assertEquals(4, managementService.createJobQuery().list().size());

  engine.close();

  // when
  engine = ProcessEngineConfiguration
  .createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/history/history-cleanup-parallelism-less.camunda.cfg.xml")
    .buildProcessEngine();

  // then
  // reconfigure history cleanup job
  managementService = engine.getManagementService();
  assertEquals(1, managementService.createJobQuery().list().size());

  Job job = managementService.createJobQuery().singleResult();
  assertEquals(0, getHistoryCleanupJobHandlerConfiguration(job).getMinuteFrom());
  assertEquals(59, getHistoryCleanupJobHandlerConfiguration(job).getMinuteTo());

  closeProcessEngine(engine);
}
 
Example 12
Source File: OSGiEventBridgeIntegrationTest.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
/**
 * We don't want to receive any more events after shutting the bundle down.
 */
@Test
public void shutdownDuringRunningProcess() throws Exception {
  TestEventHandler eventHandler = new TestEventHandler();
  registerEventHandler(eventHandler);
  final ProcessEngine processEngine = createProcessEngine();
  deployProcess(processEngine, "longRunningTestProcess", "src/test/resources/eventing/longRunningTestProcess.bpmn");
  stopEventingBundle();
  processEngine.getRuntimeService().startProcessInstanceByKey("slowProcess");
  processEngine.close();

  checkLogListener();
  assertThat(eventHandler.endCalled(), is(false));
}
 
Example 13
Source File: OSGiEventBridgeIntegrationTest.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
@Test
public void testEventBrigde() throws FileNotFoundException {
  TestEventHandler eventHandler = new TestEventHandler();
  registerEventHandler(eventHandler);
  ProcessEngine processEngine = createProcessEngine();
  deployProcess(processEngine, "testProcess", "src/test/resources/testprocess.bpmn");
  processEngine.getRuntimeService().startProcessInstanceByKey("Process_1");
  processEngine.close();

  checkLogListener();
  assertThat(eventHandler.isCalled(), is(true));
}
 
Example 14
Source File: CamundaReactorTest.java    From camunda-bpm-reactor with Apache License 2.0 5 votes vote down vote up
@Test
public void fails_to_get_eventBus_from_engine() {
  ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration(){{
    setDatabaseSchemaUpdate(ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE);
  }}.buildProcessEngine();
  try {
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("No eventBus found. Make sure the Reactor plugin is configured correctly.");

    CamundaReactor.eventBus(engine);

  } finally {
    engine.close();
  }
}
 
Example 15
Source File: CamundaReactorTest.java    From camunda-bpm-reactor with Apache License 2.0 5 votes vote down vote up
@Test
public void get_eventBus_from_default_engine() {
  CamundaEventBus camundaEventBus = new CamundaEventBus();
  ProcessEngine engine = new ReactorProcessEngineConfiguration(camundaEventBus).buildProcessEngine();

  try {
    assertThat(CamundaReactor.eventBus()).isEqualTo(camundaEventBus);
  } finally {
    engine.close();
  }
}
 
Example 16
Source File: TestHelper.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void closeProcessEngines() {
  for (ProcessEngine processEngine: processEngines.values()) {
    processEngine.close();
  }
  processEngines.clear();
}
 
Example 17
Source File: DatabaseTablePrefixTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldPerformDatabaseSchemaOperationCreate() throws Exception{

  // both process engines will be using this datasource.
  PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(),
          "org.h2.Driver",
          "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000",
          "sa",
          "" );

  // create two schemas is the database
  Connection connection = pooledDataSource.getConnection();
  connection.createStatement().execute("drop schema if exists SCHEMA1");
  connection.createStatement().execute("drop schema if exists SCHEMA2");
  connection.createStatement().execute("create schema SCHEMA1");
  connection.createStatement().execute("create schema SCHEMA2");
  connection.close();

  // configure & build two different process engines, each having a separate table prefix
  ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration()
          .setProcessEngineName("DatabaseTablePrefixTest-engine1")
          .setDataSource(pooledDataSource)
          .setDbMetricsReporterActivate(false)
          .setDatabaseSchemaUpdate("NO_CHECK"); // disable auto create/drop schema
  config1.setDatabaseTablePrefix("SCHEMA1.");
  config1.setUseSharedSqlSessionFactory(true);
  ProcessEngine engine1 = config1.buildProcessEngine();

  ProcessEngineConfigurationImpl config2 = createCustomProcessEngineConfiguration()
          .setProcessEngineName("DatabaseTablePrefixTest-engine2")
          .setDataSource(pooledDataSource)
          .setDbMetricsReporterActivate(false)
          .setDatabaseSchemaUpdate("NO_CHECK"); // disable auto create/drop schema
  config2.setDatabaseTablePrefix("SCHEMA2.");
  config2.setUseSharedSqlSessionFactory(true);
  ProcessEngine engine2 = config2.buildProcessEngine();

  // create the tables in SCHEMA1
  connection = pooledDataSource.getConnection();
  connection.createStatement().execute("set schema SCHEMA1");
  engine1.getManagementService().databaseSchemaUpgrade(connection, "", "SCHEMA1");
  connection.close();

  // create the tables in SCHEMA2
  connection = pooledDataSource.getConnection();
  connection.createStatement().execute("set schema SCHEMA2");
  engine2.getManagementService().databaseSchemaUpgrade(connection, "", "SCHEMA2");
  connection.close();

  // if I deploy a process to one engine, it is not visible to the other
  // engine:
  try {
    engine1.getRepositoryService()
      .createDeployment()
      .addClasspathResource("org/camunda/bpm/engine/test/api/cfg/oneJobProcess.bpmn20.xml")
      .deploy();

    assertEquals(1, engine1.getRepositoryService().createDeploymentQuery().count());
    assertEquals(0, engine2.getRepositoryService().createDeploymentQuery().count());

  } finally {
    engine1.close();
    engine2.close();
    ProcessEngineConfigurationImpl.cachedSqlSessionFactory = null;
  }
}
 
Example 18
Source File: TestFixture.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
  ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("camunda.cfg.xml");
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

  // register test scenarios
  ScenarioRunner runner = new ScenarioRunner(processEngine, ENGINE_VERSION);

  // event subprocesses
  runner.setupScenarios(InterruptingEventSubprocessScenario.class);
  runner.setupScenarios(NonInterruptingEventSubprocessScenario.class);
  runner.setupScenarios(NestedNonInterruptingEventSubprocessScenario.class);
  runner.setupScenarios(ParallelNestedNonInterruptingEventSubprocessScenario.class);
  runner.setupScenarios(NestedParallelNonInterruptingEventSubprocessScenario.class);
  runner.setupScenarios(NestedNonInterruptingEventSubprocessNestedSubprocessScenario.class);
  runner.setupScenarios(NestedInterruptingErrorEventSubprocessScenario.class);
  runner.setupScenarios(TwoLevelNestedNonInterruptingEventSubprocessScenario.class);
  runner.setupScenarios(NestedInterruptingEventSubprocessParallelScenario.class);

  // multi instance
  runner.setupScenarios(SequentialMultiInstanceSubprocessScenario.class);
  runner.setupScenarios(NestedSequentialMultiInstanceSubprocessScenario.class);
  runner.setupScenarios(MultiInstanceReceiveTaskScenario.class);
  runner.setupScenarios(ParallelMultiInstanceSubprocessScenario.class);

  // async
  runner.setupScenarios(AsyncParallelMultiInstanceScenario.class);
  runner.setupScenarios(AsyncSequentialMultiInstanceScenario.class);

  // boundary event
  runner.setupScenarios(NonInterruptingBoundaryEventScenario.class);
  runner.setupScenarios(NestedNonInterruptingBoundaryEventOnInnerSubprocessScenario.class);
  runner.setupScenarios(NestedNonInterruptingBoundaryEventOnOuterSubprocessScenario.class);

  // compensation
  runner.setupScenarios(SingleActivityCompensationScenario.class);
  runner.setupScenarios(SubprocessCompensationScenario.class);
  runner.setupScenarios(TransactionCancelCompensationScenario.class);
  runner.setupScenarios(InterruptingEventSubprocessCompensationScenario.class);
  runner.setupScenarios(SubprocessParallelThrowCompensationScenario.class);
  runner.setupScenarios(SubprocessParallelCreateCompensationScenario.class);

  // plain tasks
  runner.setupScenarios(OneTaskScenario.class);
  runner.setupScenarios(OneScopeTaskScenario.class);
  runner.setupScenarios(ParallelTasksScenario.class);
  runner.setupScenarios(ParallelScopeTasksScenario.class);

  // event-based gateway
  runner.setupScenarios(EventBasedGatewayScenario.class);

  runner.setupScenarios(HistoricInstancePermissionsWithoutProcDefKeyScenario.class);

  processEngine.close();
}
 
Example 19
Source File: RuntimeServiceTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void testStartProcessInstanceByIdAfterReboot() {

  // In case this test is run in a test suite, previous engines might
  // have been initialized and cached.  First we close the
  // existing process engines to make sure that the db is clean
  // and that there are no existing process engines involved.
  ProcessEngines.destroy();

  // Creating the DB schema (without building a process engine)
  ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
  processEngineConfiguration.setProcessEngineName("reboot-test-schema");
  processEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000");
  ProcessEngine schemaProcessEngine = processEngineConfiguration.buildProcessEngine();

  // Create process engine and deploy test process
  ProcessEngine processEngine = new StandaloneProcessEngineConfiguration()
    .setProcessEngineName("reboot-test")
    .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
    .setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000")
    .setJobExecutorActivate(false)
    .buildProcessEngine();

  processEngine.getRepositoryService()
    .createDeployment()
    .addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
    .deploy();
    // verify existence of process definition
  List<ProcessDefinition> processDefinitions = processEngine
    .getRepositoryService()
    .createProcessDefinitionQuery()
    .list();

  assertEquals(1, processDefinitions.size());

  // Start a new Process instance
  ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId());
  String processInstanceId = processInstance.getId();
  assertNotNull(processInstance);

  // Close the process engine
  processEngine.close();
  assertNotNull(processEngine.getRuntimeService());

  // Reboot the process engine
  processEngine = new StandaloneProcessEngineConfiguration()
    .setProcessEngineName("reboot-test")
    .setDatabaseSchemaUpdate(org.camunda.bpm.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
    .setJdbcUrl("jdbc:h2:mem:activiti-reboot-test;DB_CLOSE_DELAY=1000")
    .setJobExecutorActivate(false)
    .buildProcessEngine();

  // Check if the existing process instance is still alive
  processInstance = processEngine
    .getRuntimeService()
    .createProcessInstanceQuery()
    .processInstanceId(processInstanceId)
    .singleResult();

  assertNotNull(processInstance);

  // Complete the task.  That will end the process instance
  TaskService taskService = processEngine.getTaskService();
  Task task = taskService
    .createTaskQuery()
    .list()
    .get(0);
  taskService.complete(task.getId());

  // Check if the process instance has really ended.  This means that the process definition has
  // re-loaded into the process definition cache
  processInstance = processEngine
    .getRuntimeService()
    .createProcessInstanceQuery()
    .processInstanceId(processInstanceId)
    .singleResult();
  assertNull(processInstance);

  // Extra check to see if a new process instance can be started as well
  processInstance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitions.get(0).getId());
  assertNotNull(processInstance);

  // close the process engine
  processEngine.close();

  // Cleanup schema
  schemaProcessEngine.close();
}
 
Example 20
Source File: DbSchemaExecuteFile.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {

  if(args.length != 2) {
    throw LOG.invokeSchemaResourceToolException(args.length);
  }

  final String configurationFileResourceName = args[0];
  final String schemaFileResourceName = args[1];

  ensureNotNull("Process engine configuration file name cannot be null", "configurationFileResourceName", configurationFileResourceName);
  ensureNotNull("Schema resource file name cannot be null", "schemaFileResourceName", schemaFileResourceName);

  ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(configurationFileResourceName);
  ProcessEngine processEngine = configuration.buildProcessEngine();

  configuration.getCommandExecutorTxRequired().execute(new Command<Void>() {

    public Void execute(CommandContext commandContext) {

      commandContext.getDbSqlSession()
        .executeSchemaResource(schemaFileResourceName);

      return null;
    }

  });

  processEngine.close();

}