use of org.camunda.bpm.application.InvocationContext in project camunda-bpm-platform by camunda.
the class CommandInvocationContext method performNext.
protected void performNext() {
AtomicOperationInvocation nextInvocation = queuedInvocations.get(0);
if (nextInvocation.operation.isAsyncCapable() && isExecuting) {
// will be picked up by while loop below
return;
}
ProcessApplicationReference targetProcessApplication = getTargetProcessApplication(nextInvocation.execution);
if (requiresContextSwitch(targetProcessApplication)) {
Context.executeWithinProcessApplication(new Callable<Void>() {
public Void call() throws Exception {
performNext();
return null;
}
}, targetProcessApplication, new InvocationContext(nextInvocation.execution));
} else {
if (!nextInvocation.operation.isAsyncCapable()) {
// if operation is not async capable, perform right away.
invokeNext();
} else {
try {
isExecuting = true;
while (!queuedInvocations.isEmpty()) {
// assumption: all operations are executed within the same process application...
nextInvocation = queuedInvocations.get(0);
invokeNext();
}
} finally {
isExecuting = false;
}
}
}
}
use of org.camunda.bpm.application.InvocationContext in project camunda-bpm-platform by camunda.
the class InvocationContextTest method testInvokeProcessApplicationWithContextOnStart.
@Test
@OperateOnDeployment("app")
public void testInvokeProcessApplicationWithContextOnStart() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("messageProcess");
InvocationContext invocationContext = ProcessApplicationWithInvocationContext.getInvocationContext();
assertThat(invocationContext, is(notNullValue()));
assertThat(invocationContext.getExecution(), is(notNullValue()));
assertThat(invocationContext.getExecution().getId(), is(pi.getId()));
}
Aggregations