Java Code Examples for org.camunda.bpm.BpmPlatform#getDefaultProcessEngine()

The following examples show how to use org.camunda.bpm.BpmPlatform#getDefaultProcessEngine() . 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: SpringProcessApplicationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployProcessArchive() {

  // start a spring application context
  AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/camunda/bpm/engine/spring/test/application/SpringProcessArchiveDeploymentTest-context.xml");
  applicationContext.start();

  // assert the process archive is deployed:
  ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();
  Assert.assertNotNull(processEngine.getRepositoryService().createDeploymentQuery().deploymentName("pa").singleResult());

  applicationContext.close();

  // assert the process is undeployed
  Assert.assertNull(processEngine.getRepositoryService().createDeploymentQuery().deploymentName("pa").singleResult());

}
 
Example 2
Source File: Application.java    From camunda-spring-boot-amqp-microservice-cloud-example with Apache License 2.0 5 votes vote down vote up
public static void main(String... args) {
  SpringApplication.run(Application.class, args);

  // do default setup of platform
  ProcessEngine engine = BpmPlatform.getDefaultProcessEngine();
  createDefaultUser(engine);
  //setCamundaEELicenseKey(engine);
}
 
Example 3
Source File: TripBookinApplication.java    From trip-booking-saga-java with Apache License 2.0 5 votes vote down vote up
public static void main(String... args) throws Exception {
  SpringApplication.run(TripBookinApplication.class, args);

  // do default setup of platform (everything is only applied if not yet there)
  ProcessEngine engine = BpmPlatform.getDefaultProcessEngine();
  
  // start a Saga right away
  engine.getRuntimeService().startProcessInstanceByKey(
      "trip", 
      Variables.putValue("someVariableToPass", "someValue"));
  
  // Start H2 server to be able to connect to database from the outside
  Server.createTcpServer(new String[] { "-tcpPort", "8092", "-tcpAllowOthers" }).start();
}
 
Example 4
Source File: CompleteTaskCommand.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(Optional<AjaxRequestTarget> targetOptional) {
	super.onClick(targetOptional);
	ODocument doc = getModelObject();
	ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();
	TaskService taskService = processEngine.getTaskService();
	String taskId = taskModel.getObject().field("id");
	String var = formKey.getVariableName();
	taskService.complete(taskId, CommonUtils.<String, Object>toMap(var, doc.getIdentity().toString()));
	setResponsePage(new ODocumentPage(doc));
	sendActionPerformed();
}
 
Example 5
Source File: TaskFormWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected FormKey obtainFormKey() {
	               ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();
	               TaskService taskService = processEngine.getTaskService();
	               Task task = taskService.createTaskQuery()
                                          .taskId((String)getModelObject().field("id"))
                                          .initializeFormKeys()
                                          .singleResult();
	               return FormKey.parse(task.getFormKey());
}
 
Example 6
Source File: ContainerManagedProcessEngineProvider.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessEngine getDefaultProcessEngine() {
  ProcessEngine defaultProcessEngine = BpmPlatform.getDefaultProcessEngine();
  if(defaultProcessEngine != null) {
    return defaultProcessEngine;
  } else {
    return ProcessEngines.getDefaultProcessEngine(false);
  }
}
 
Example 7
Source File: EnsureCleanDbPlugin.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("resource")
@Override
public void postProcessApplicationUndeploy(ProcessApplicationInterface processApplication) {
  // some tests deploy multiple PAs. => only clean DB after last PA is undeployed
  // if the deployment fails for example during parsing the deployment counter was not incremented
  // so we have to check if the counter is already zero otherwise we go into the negative values
  // best example is TestWarDeploymentWithBrokenBpmnXml in integration-test-engine test suite
  if(counter.get() == 0 || counter.decrementAndGet() == 0) {

    final ProcessEngine defaultProcessEngine = BpmPlatform.getDefaultProcessEngine();
    try {
      logger.log(Level.INFO, "=== Ensure Clean Database ===");
      ManagementServiceImpl managementService = (ManagementServiceImpl) defaultProcessEngine.getManagementService();
      PurgeReport report = managementService.purge();

      if (report.isEmpty()) {
        logger.log(Level.INFO, "Clean DB and cache.");
      } else {
        StringBuilder builder = new StringBuilder();

        DatabasePurgeReport databasePurgeReport = report.getDatabasePurgeReport();
        if (!databasePurgeReport.isEmpty()) {
          builder.append(DATABASE_NOT_CLEAN).append(databasePurgeReport.getPurgeReportAsString());
        }

        CachePurgeReport cachePurgeReport = report.getCachePurgeReport();
        if (!cachePurgeReport.isEmpty()) {
          builder.append(CACHE_IS_NOT_CLEAN).append(cachePurgeReport.getPurgeReportAsString());
        }
        logger.log(Level.INFO, builder.toString());
      }
    }
    catch(Throwable e) {
      logger.log(Level.SEVERE, "Could not clean DB:", e);
    }
  }

}
 
Example 8
Source File: TaskFormWidget.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
protected void associateTaskWithDocument(String taskId, ODocument doc) {
	ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();
	TaskService taskService = processEngine.getTaskService();
	String var = formKey.getVariableName();
	taskService.setVariable(taskId, var, doc.getIdentity().toString());
}
 
Example 9
Source File: CustomProcessEngineProvider.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessEngine getDefaultProcessEngine() {
  return BpmPlatform.getDefaultProcessEngine();
}
 
Example 10
Source File: SpringProcessApplicationTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void testPostDeployRegistrationPa() {
  // this test verifies that a process application is able to register a deployment from the @PostDeploy callback:

  AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/camunda/bpm/engine/spring/test/application/PostDeployRegistrationPaTest-context.xml");
  applicationContext.start();

  ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();

  // create a manual deployment:
  Deployment deployment = processEngine.getRepositoryService()
    .createDeployment()
    .addClasspathResource("org/camunda/bpm/engine/spring/test/application/process.bpmn20.xml")
    .deploy();

  // lookup the process application spring bean:
  PostDeployRegistrationPa processApplication = applicationContext.getBean("customProcessApplicaiton", PostDeployRegistrationPa.class);

  Assert.assertFalse(processApplication.isPostDeployInvoked());
  processApplication.deploy();
  Assert.assertTrue(processApplication.isPostDeployInvoked());

  // the process application was not invoked
  Assert.assertFalse(processApplication.isInvoked());

  // start process instance:
  processEngine.getRuntimeService()
    .startProcessInstanceByKey("startToEnd");

  // now the process application was invoked:
  Assert.assertTrue(processApplication.isInvoked());

  // undeploy PA
  Assert.assertFalse(processApplication.isPreUndeployInvoked());
  processApplication.undeploy();
  Assert.assertTrue(processApplication.isPreUndeployInvoked());

  // manually undeploy the process
  processEngine.getRepositoryService()
    .deleteDeployment(deployment.getId(), true);

  applicationContext.close();

}