本文整理汇总了Java中org.camunda.bpm.engine.impl.interceptor.CommandExecutor类的典型用法代码示例。如果您正苦于以下问题:Java CommandExecutor类的具体用法?Java CommandExecutor怎么用?Java CommandExecutor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommandExecutor类属于org.camunda.bpm.engine.impl.interceptor包,在下文中一共展示了CommandExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testJobsWithoutDeploymentIdAreAlwaysProcessed
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
public void testJobsWithoutDeploymentIdAreAlwaysProcessed() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
String messageId = commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
MessageEntity message = new MessageEntity();
commandContext.getJobManager().send(message);
return message.getId();
}
});
AcquiredJobs acquiredJobs = getExecutableJobs(processEngineConfiguration.getJobExecutor());
Assert.assertEquals(1, acquiredJobs.size());
Assert.assertTrue(acquiredJobs.contains(messageId));
commandExecutor.execute(new DeleteJobsCmd(messageId, true));
}
示例2: createJobWithoutExceptionStacktrace
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
private void createJobWithoutExceptionStacktrace() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
JobManager jobManager = commandContext.getJobManager();
timerEntity = new TimerEntity();
timerEntity.setLockOwner(UUID.randomUUID().toString());
timerEntity.setDuedate(new Date());
timerEntity.setRetries(0);
timerEntity.setExceptionMessage("I'm supposed to fail");
jobManager.insert(timerEntity);
assertNotNull(timerEntity.getId());
return null;
}
});
}
示例3: testDiagramCreationDisabled
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
public void testDiagramCreationDisabled() {
repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/parse/BpmnParseTest.testParseDiagramInterchangeElements.bpmn20.xml").deploy();
// Graphical information is not yet exposed publicly, so we need to do some plumbing
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
@Override
public ProcessDefinitionEntity execute(CommandContext commandContext) {
return Context.getProcessEngineConfiguration()
.getDeploymentCache()
.findDeployedLatestProcessDefinitionByKey("myProcess");
}
});
assertNotNull(processDefinitionEntity);
assertEquals(7, processDefinitionEntity.getActivities().size());
// Check that no diagram has been created
List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
assertEquals(1, resourceNames.size());
repositoryService.deleteDeployment(repositoryService.createDeploymentQuery().singleResult().getId(), true);
}
示例4: createJobWithoutExceptionMsg
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
private void createJobWithoutExceptionMsg() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
JobManager jobManager = commandContext.getJobManager();
timerEntity = new TimerEntity();
timerEntity.setLockOwner(UUID.randomUUID().toString());
timerEntity.setDuedate(new Date());
timerEntity.setRetries(0);
StringWriter stringWriter = new StringWriter();
NullPointerException exception = new NullPointerException();
exception.printStackTrace(new PrintWriter(stringWriter));
timerEntity.setExceptionStacktrace(stringWriter.toString());
jobManager.insert(timerEntity);
assertNotNull(timerEntity.getId());
return null;
}
});
}
示例5: deleteJobAndIncidents
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
protected void deleteJobAndIncidents(final Job job) {
final List<HistoricIncident> incidents =
historyService.createHistoricIncidentQuery()
.incidentType(Incident.FAILED_JOB_HANDLER_TYPE).list();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
((JobEntity) job).delete();
HistoricIncidentManager historicIncidentManager = commandContext.getHistoricIncidentManager();
for (HistoricIncident incident : incidents) {
HistoricIncidentEntity incidentEntity = (HistoricIncidentEntity) incident;
historicIncidentManager.delete(incidentEntity);
}
commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(job.getId());
return null;
}
});
}
示例6: testSetProcessDefinitionVersionPIIsSubExecution
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
@Deployment(resources = {TEST_PROCESS_WITH_PARALLEL_GATEWAY})
public void testSetProcessDefinitionVersionPIIsSubExecution() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoin");
Execution execution = runtimeService.createExecutionQuery()
.activityId("receivePayment")
.singleResult();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
SetProcessDefinitionVersionCmd command = new SetProcessDefinitionVersionCmd(execution.getId(), 1);
try {
commandExecutor.execute(command);
fail("ProcessEngineException expected");
} catch (ProcessEngineException ae) {
assertTextPresent("A process instance id is required, but the provided id '"+execution.getId()+"' points to a child execution of process instance '"+pi.getId()+"'. Please invoke the "+command.getClass().getSimpleName()+" with a root execution id.", ae.getMessage());
}
}
示例7: forExecution
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
public static ExecutionTree forExecution(final String executionId, ProcessEngine processEngine) {
ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl)
processEngine.getProcessEngineConfiguration();
CommandExecutor commandExecutor = configuration.getCommandExecutorTxRequired();
ExecutionTree executionTree = commandExecutor.execute(new Command<ExecutionTree>() {
public ExecutionTree execute(CommandContext commandContext) {
ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(executionId);
return ExecutionTree.forExecution(execution);
}
});
return executionTree;
}
示例8: testSetProcessDefinitionVersionActivityMissing
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
@Deployment(resources = {TEST_PROCESS})
public void testSetProcessDefinitionVersionActivityMissing() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
// check that receive task has been reached
Execution execution = runtimeService.createExecutionQuery()
.activityId("waitState1")
.singleResult();
assertNotNull(execution);
// deploy new version of the process definition
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService
.createDeployment()
.addClasspathResource(TEST_PROCESS_ACTIVITY_MISSING)
.deploy();
assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
// migrate process instance to new process definition version
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
SetProcessDefinitionVersionCmd setProcessDefinitionVersionCmd = new SetProcessDefinitionVersionCmd(pi.getId(), 2);
try {
commandExecutor.execute(setProcessDefinitionVersionCmd);
fail("ProcessEngineException expected");
} catch (ProcessEngineException ae) {
assertTextPresent("The new process definition (key = 'receiveTask') does not contain the current activity (id = 'waitState1') of the process instance (id = '", ae.getMessage());
}
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
}
示例9: testTablePresentWithSchemaAndPrefix
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
public void testTablePresentWithSchemaAndPrefix() throws SQLException {
PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver",
"jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", "");
Connection connection = pooledDataSource.getConnection();
connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME);
connection.createStatement().execute("create schema " + SCHEMA_NAME);
connection.createStatement().execute("create table " + SCHEMA_NAME + "." + PREFIX_NAME + "SOME_TABLE(id varchar(64));");
connection.close();
ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1")
// disable auto create/drop schema
.setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK");
config1.setDatabaseTablePrefix(SCHEMA_NAME + "." + PREFIX_NAME);
config1.setDatabaseSchema(SCHEMA_NAME);
config1.setDbMetricsReporterActivate(false);
ProcessEngine engine = config1.buildProcessEngine();
CommandExecutor commandExecutor = config1.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>(){
public Void execute(CommandContext commandContext) {
DbSqlSession sqlSession = commandContext.getSession(DbSqlSession.class);
assertTrue(sqlSession.isTablePresent("SOME_TABLE"));
return null;
}
});
engine.close();
}
示例10: testSetProcessDefinitionVersionWithCallActivity
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
@Deployment(resources = {TEST_PROCESS_CALL_ACTIVITY})
public void testSetProcessDefinitionVersionWithCallActivity() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("parentProcess");
// check that receive task has been reached
Execution execution = runtimeService.createExecutionQuery()
.activityId("waitState1")
.processDefinitionKey("childProcess")
.singleResult();
assertNotNull(execution);
// deploy new version of the process definition
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService
.createDeployment()
.addClasspathResource(TEST_PROCESS_CALL_ACTIVITY)
.deploy();
assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("parentProcess").count());
// migrate process instance to new process definition version
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 2));
// signal process instance
runtimeService.signal(execution.getId());
// should be finished now
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).count());
// undeploy "manually" deployed process definition
repositoryService.deleteDeployment(deployment.getId(), true);
}
示例11: clearDatabase
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
protected void clearDatabase() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
List<HistoricIncident> incidents = Context.getProcessEngineConfiguration().getHistoryService().createHistoricIncidentQuery().list();
for (HistoricIncident incident : incidents) {
commandContext.getHistoricIncidentManager().delete((HistoricIncidentEntity) incident);
}
return null;
}
});
}
示例12: RestartProcessInstanceBuilderImpl
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
public RestartProcessInstanceBuilderImpl(CommandExecutor commandExecutor, String processDefinitionId) {
ensureNotNull(NotValidException.class, "processDefinitionId", processDefinitionId);
this.commandExecutor = commandExecutor;
this.instructions = new ArrayList<AbstractProcessInstanceModificationCommand>();
this.processDefinitionId = processDefinitionId;
this.processInstanceIds = new ArrayList<String>();
}
示例13: testSetProcessDefinitionVersionMigrateIncident
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
@Deployment(resources = TEST_PROCESS_ONE_JOB)
public void testSetProcessDefinitionVersionMigrateIncident() {
// given a process instance
ProcessInstance instance =
runtimeService.startProcessInstanceByKey("oneJobProcess", Variables.createVariables().putValue("shouldFail", true));
// with a failed job
executeAvailableJobs();
// and an incident
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
// and a second deployment of the process
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService
.createDeployment()
.addClasspathResource(TEST_PROCESS_ONE_JOB)
.deploy();
ProcessDefinition newDefinition =
repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
assertNotNull(newDefinition);
// when the process instance is migrated
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new SetProcessDefinitionVersionCmd(instance.getId(), 2));
// then the the incident should also be migrated
Incident migratedIncident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(migratedIncident);
assertEquals(newDefinition.getId(), migratedIncident.getProcessDefinitionId());
assertEquals(instance.getId(), migratedIncident.getProcessInstanceId());
assertEquals(instance.getId(), migratedIncident.getExecutionId());
repositoryService.deleteDeployment(deployment.getId(), true);
}
示例14: tearDown
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
@Override
public void tearDown() throws Exception {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerActivateProcessDefinitionHandler.TYPE);
return null;
}
});
}
示例15: main
import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; //导入依赖的package包/类
public static void main(String[] args) {
ProcessEngineImpl processEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
CommandExecutor commandExecutor = processEngine.getProcessEngineConfiguration().getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Object> (){
public Object execute(CommandContext commandContext) {
commandContext
.getSession(PersistenceSession.class)
.dbSchemaPrune();
return null;
}
});
}