use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.
the class AtomicOperationInvocation method execute.
public void execute(BpmnStackTrace stackTrace) {
if (operation != PvmAtomicOperation.ACTIVITY_START_CANCEL_SCOPE && operation != PvmAtomicOperation.ACTIVITY_START_INTERRUPT_SCOPE && operation != PvmAtomicOperation.ACTIVITY_START_CONCURRENT) {
// execution might be replaced in the meantime:
ExecutionEntity replacedBy = execution.getReplacedBy();
if (replacedBy != null) {
execution = replacedBy;
}
}
// execution was canceled for example via terminate end event
if (execution.isCanceled() && (operation == PvmAtomicOperation.TRANSITION_NOTIFY_LISTENER_END || operation == PvmAtomicOperation.ACTIVITY_NOTIFY_LISTENER_END)) {
return;
}
// execution might have ended in the meanwhile
if (execution.isEnded() && (operation == PvmAtomicOperation.TRANSITION_NOTIFY_LISTENER_TAKE || operation == PvmAtomicOperation.ACTIVITY_START_CREATE_SCOPE)) {
return;
}
ProcessApplicationReference currentPa = Context.getCurrentProcessApplication();
if (currentPa != null) {
applicationContextName = currentPa.getName();
}
activityId = execution.getActivityId();
activityName = execution.getCurrentActivityName();
stackTrace.add(this);
try {
Context.setExecutionContext(execution);
if (!performAsync) {
LOG.debugExecutingAtomicOperation(operation, execution);
operation.execute(execution);
} else {
execution.scheduleAtomicOperationAsync(this);
}
} finally {
Context.removeExecutionContext();
}
}
use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.
the class ProcessApplicationContextTest method testExecutionInPAContextByReference.
public void testExecutionInPAContextByReference() throws Exception {
Assert.assertNull(Context.getCurrentProcessApplication());
ProcessApplicationReference contextPA = ProcessApplicationContext.withProcessApplicationContext(new Callable<ProcessApplicationReference>() {
@Override
public ProcessApplicationReference call() throws Exception {
return getCurrentContextApplication();
}
}, pa.getReference());
Assert.assertEquals(contextPA.getProcessApplication(), pa);
Assert.assertNull(Context.getCurrentProcessApplication());
}
use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.
the class ProcessApplicationContextTest method testExecuteWithInvocationContext.
@SuppressWarnings("unchecked")
public void testExecuteWithInvocationContext() throws Exception {
// given a process application which extends the default one
// - using a spy for verify the invocations
TestApplicationWithoutEngine processApplication = spy(pa);
ProcessApplicationReference processApplicationReference = mock(ProcessApplicationReference.class);
when(processApplicationReference.getProcessApplication()).thenReturn(processApplication);
// when execute with context
InvocationContext invocationContext = new InvocationContext(mock(BaseDelegateExecution.class));
Context.executeWithinProcessApplication(mock(Callable.class), processApplicationReference, invocationContext);
// then the execute method should be invoked with context
verify(processApplication).execute(any(Callable.class), eq(invocationContext));
// and forward to call to the default execute method
verify(processApplication).execute(any(Callable.class));
}
use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.
the class ProcessApplicationContextTest method testExecutionInPAContextByName.
public void testExecutionInPAContextByName() throws Exception {
Assert.assertNull(Context.getCurrentProcessApplication());
ProcessApplicationReference contextPA = ProcessApplicationContext.withProcessApplicationContext(new Callable<ProcessApplicationReference>() {
@Override
public ProcessApplicationReference call() throws Exception {
return getCurrentContextApplication();
}
}, pa.getName());
Assert.assertEquals(contextPA.getProcessApplication(), pa);
Assert.assertNull(Context.getCurrentProcessApplication());
}
use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.
the class ProcessApplicationContextTest method testExecutionInPAContextbyRawPA.
public void testExecutionInPAContextbyRawPA() throws Exception {
Assert.assertNull(Context.getCurrentProcessApplication());
ProcessApplicationReference contextPA = ProcessApplicationContext.withProcessApplicationContext(new Callable<ProcessApplicationReference>() {
@Override
public ProcessApplicationReference call() throws Exception {
return getCurrentContextApplication();
}
}, pa);
Assert.assertEquals(contextPA.getProcessApplication(), pa);
Assert.assertNull(Context.getCurrentProcessApplication());
}
Aggregations