本文整理汇总了Java中org.camunda.bpm.engine.delegate.ExecutionListener类的典型用法代码示例。如果您正苦于以下问题:Java ExecutionListener类的具体用法?Java ExecutionListener怎么用?Java ExecutionListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExecutionListener类属于org.camunda.bpm.engine.delegate包,在下文中一共展示了ExecutionListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExecutionListener
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
@Deployment
public void testExecutionListener() {
final AtomicInteger eventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
// this process application returns an execution listener
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
eventCount.incrementAndGet();
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// start process instance
runtimeService.startProcessInstanceByKey("startToEnd");
// 7 events received
assertEquals(7, eventCount.get());
}
示例2: createEvent
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
protected BusinessProcessEvent createEvent(DelegateExecution execution) {
ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition();
// map type
String eventName = execution.getEventName();
BusinessProcessEventType type = null;
if(ExecutionListener.EVENTNAME_START.equals(eventName)) {
type = BusinessProcessEventType.START_ACTIVITY;
} else if(ExecutionListener.EVENTNAME_END.equals(eventName)) {
type = BusinessProcessEventType.END_ACTIVITY;
} else if(ExecutionListener.EVENTNAME_TAKE.equals(eventName)) {
type = BusinessProcessEventType.TAKE;
}
return new CdiBusinessProcessEvent(execution.getCurrentActivityId(), execution.getCurrentTransitionId(), processDefinition, execution, type, ClockUtil.getCurrentTime());
}
示例3: notifyExecutionListener
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
protected void notifyExecutionListener(DelegateExecution execution) throws Exception {
ProcessApplicationReference processApp = Context.getCurrentProcessApplication();
try {
ProcessApplicationInterface processApplication = processApp.getProcessApplication();
ExecutionListener executionListener = processApplication.getExecutionListener();
if(executionListener != null) {
executionListener.notify(execution);
} else {
LOG.paDoesNotProvideExecutionListener(processApp.getName());
}
} catch (ProcessApplicationUnavailableException e) {
// Process Application unavailable => ignore silently
LOG.cannotInvokeListenerPaUnavailable(processApp.getName(), e);
}
}
示例4: getExecutionListener
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
public ExecutionListener getExecutionListener() {
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
int listenerInvocationCount = 0;
if(execution.hasVariable(LISTENER_INVOCATION_COUNT)) {
listenerInvocationCount = (Integer) execution.getVariable(LISTENER_INVOCATION_COUNT);
}
listenerInvocationCount += 1;
execution.setVariable(LISTENER_INVOCATION_COUNT, listenerInvocationCount);
}
};
}
示例5: getBpmnModelElementInstance
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
public FlowElement getBpmnModelElementInstance() {
BpmnModelInstance bpmnModelInstance = getBpmnModelInstance();
if (bpmnModelInstance != null) {
ModelElementInstance modelElementInstance = null;
if (ExecutionListener.EVENTNAME_TAKE.equals(eventName)) {
modelElementInstance = bpmnModelInstance.getModelElementById(transition.getId());
} else {
modelElementInstance = bpmnModelInstance.getModelElementById(activityId);
}
try {
return (FlowElement) modelElementInstance;
} catch (ClassCastException e) {
ModelElementType elementType = modelElementInstance.getElementType();
throw LOG.castModelInstanceException(modelElementInstance, "FlowElement", elementType.getTypeName(),
elementType.getTypeNamespace(), e);
}
} else {
return null;
}
}
示例6: parseExecutionListenersOnScope
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
/**
* Parses all execution-listeners on a scope.
*
* @param scopeElement
* the XML element containing the scope definition.
* @param scope
* the scope to add the executionListeners to.
*/
public void parseExecutionListenersOnScope(Element scopeElement, ScopeImpl scope) {
Element extentionsElement = scopeElement.element("extensionElements");
if (extentionsElement != null) {
List<Element> listenerElements = extentionsElement.elementsNS(CAMUNDA_BPMN_EXTENSIONS_NS, "executionListener");
for (Element listenerElement : listenerElements) {
String eventName = listenerElement.attribute("event");
if (isValidEventNameForScope(eventName, listenerElement)) {
ExecutionListener listener = parseExecutionListener(listenerElement);
if (listener != null) {
scope.addExecutionListener(eventName, listener);
}
}
}
}
}
示例7: notify
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
public void notify(DelegateExecution execution) throws Exception {
// Note: we can't cache the result of the expression, because the
// execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
Object delegate = expression.getValue(execution);
applyFieldDeclaration(fieldDeclarations, delegate);
if (delegate instanceof ExecutionListener) {
Context.getProcessEngineConfiguration()
.getDelegateInterceptor()
.handleInvocation(new ExecutionListenerInvocation((ExecutionListener) delegate, execution));
} else if (delegate instanceof JavaDelegate) {
Context.getProcessEngineConfiguration()
.getDelegateInterceptor()
.handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution));
} else {
throw LOG.resolveDelegateExpressionException(expression, ExecutionListener.class, JavaDelegate.class);
}
}
示例8: testShouldInvokeExecutionListenerOnStartAndEndOfProcessInstance
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
@Deployment(resources = { "org/camunda/bpm/application/impl/event/ProcessApplicationEventListenerTest.testExecutionListener.bpmn20.xml" })
public void testShouldInvokeExecutionListenerOnStartAndEndOfProcessInstance() {
final AtomicInteger processDefinitionEventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
// this process application returns an execution listener
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
if (((CoreExecution) execution).getEventSource() instanceof ProcessDefinitionEntity)
processDefinitionEventCount.incrementAndGet();
}
};
}
};
// register app so that it receives events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// Start process instance.
runtimeService.startProcessInstanceByKey("startToEnd");
// Start and end of the process
assertEquals(2, processDefinitionEventCount.get());
}
示例9: testSetVariableInEndListener
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
@Test
public void testSetVariableInEndListener() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
.startEvent()
.userTask(TASK_BEFORE_CONDITION_ID)
.name(TASK_BEFORE_CONDITION)
.camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, specifier.getDelegateClass().getName())
.userTask(TASK_WITH_CONDITION_ID)
.endEvent()
.done();
deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, specifier.getCondition(), true);
// given
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task task = taskQuery.singleResult();
//when task is completed
taskService.complete(task.getId());
//then end listener sets variable
//conditional event is triggered
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(specifier.getExpectedInterruptingCount(), taskQuery.taskName(TASK_AFTER_CONDITION).count());
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:27,代码来源:TriggerConditionalEventFromDelegationCodeTest.java
示例10: testSetVariableInStartListenerOfAsyncStartEvent
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
public void testSetVariableInStartListenerOfAsyncStartEvent () throws Exception {
//given
BpmnModelInstance subProcess = Bpmn.createExecutableProcess("process")
.startEvent()
.camundaAsyncBefore()
.camundaExecutionListenerClass(ExecutionListener.EVENTNAME_START, SubProcessActivityStartListener.class.getName())
.endEvent()
.done();
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment()
.addModelInstance("process.bpmn", subProcess)
.deploy();
//when
runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("executionListenerCounter",1));
managementService.executeJob(managementService.createJobQuery().active().singleResult().getId());
//then
assertThat(historyService.createHistoricVariableInstanceQuery().count(), is (2L));
repositoryService.deleteDeployment(deployment.getId(),true);
}
示例11: testCompleteWithNonLocalVariables
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
public void testCompleteWithNonLocalVariables() {
// given
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().serviceTask("externalTask")
.camundaType("external").camundaTopic("foo").camundaTaskPriority("100")
.camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadLocalVariableListenerImpl.class)
.userTask("user").endEvent().done();
deployment(instance);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
List<LockedExternalTask> lockedTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic("foo", 1L).execute();
// when
externalTaskService.complete(lockedTasks.get(0).getId(), WORKER_ID,
Variables.createVariables().putValue("abc", "bar"), null);
// then
VariableInstance variableInstance = runtimeService.createVariableInstanceQuery()
.processInstanceIdIn(processInstance.getId()).singleResult();
assertNotNull(variableInstance);
assertEquals("bar", variableInstance.getValue());
assertEquals("abc", variableInstance.getName());
}
示例12: testSetVariableInEndListenerOfAsyncStartEvent
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
public void testSetVariableInEndListenerOfAsyncStartEvent () throws Exception {
//given
BpmnModelInstance subProcess = Bpmn.createExecutableProcess("process")
.startEvent()
.camundaAsyncBefore()
.camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, SubProcessActivityStartListener.class.getName())
.endEvent()
.done();
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment()
.addModelInstance("process.bpmn", subProcess)
.deploy();
//when
runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValue("executionListenerCounter",1));
managementService.executeJob(managementService.createJobQuery().active().singleResult().getId());
//then
assertThat(historyService.createHistoricVariableInstanceQuery().count(), is (2L));
repositoryService.deleteDeployment(deployment.getId(),true);
}
示例13: testNoListenersCalled
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
@Test
public void testNoListenersCalled() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL)
.activityBuilder("subProcess")
.camundaExecutionListenerClass(
ExecutionListener.EVENTNAME_END,
RecorderExecutionListener.class.getName())
.done());
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId())
.mapActivities("userTask2", "userTask2")
.mapActivities("compensationBoundary", "compensationBoundary")
.build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
testHelper.completeTask("userTask1");
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
// the listener was only called once when the sub process completed properly
Assert.assertEquals(1, RecorderExecutionListener.getRecordedEvents().size());
}
示例14: shouldSkipCustomListeners
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
@Test
public void shouldSkipCustomListeners() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(ProcessModels.TWO_TASKS_PROCESS).activityBuilder("userTask1")
.camundaExecutionListenerClass(ExecutionListener.EVENTNAME_START, IncrementCounterListener.class.getName()).done());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
IncrementCounterListener.counter = 0;
// when
runtimeService.restartProcessInstances(processDefinition.getId())
.startBeforeActivity("userTask1")
.processInstanceIds(processInstance.getId())
.skipCustomListeners()
.execute();
// then
assertEquals(0, IncrementCounterListener.counter);
}
示例15: testSkipListenerInvocationF
import org.camunda.bpm.engine.delegate.ExecutionListener; //导入依赖的package包/类
@Test
public void testSkipListenerInvocationF() {
// given
DelegateEvent.clearEvents();
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(instance)
.activityBuilder("user2")
.camundaExecutionListenerClass(ExecutionListener.EVENTNAME_START, DelegateExecutionListener.class.getName())
.done());
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
Batch batch = runtimeService
.createModification(processDefinition.getId())
.cancelAllForActivity("user2")
.processInstanceIds(Arrays.asList(processInstance.getId()))
.skipCustomListeners()
.executeAsync();
helper.executeSeedJob(batch);
// when
helper.executeJobs(batch);
// then
assertEquals(0, DelegateEvent.getEvents().size());
}