Search in sources :

Example 21 with ProcessApplicationReference

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();
    }
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Example 22 with ProcessApplicationReference

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());
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException)

Example 23 with ProcessApplicationReference

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));
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) BaseDelegateExecution(org.camunda.bpm.engine.delegate.BaseDelegateExecution) TestApplicationWithoutEngine(org.camunda.bpm.application.impl.embedded.TestApplicationWithoutEngine) InvocationContext(org.camunda.bpm.application.InvocationContext) Callable(java.util.concurrent.Callable)

Example 24 with ProcessApplicationReference

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());
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException)

Example 25 with ProcessApplicationReference

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());
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessApplicationUnavailableException(org.camunda.bpm.application.ProcessApplicationUnavailableException)

Aggregations

ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)39 Deployment (org.camunda.bpm.engine.repository.Deployment)10 Test (org.junit.Test)10 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)7 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)7 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)6 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5 ProcessApplicationInterface (org.camunda.bpm.application.ProcessApplicationInterface)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 RepositoryService (org.camunda.bpm.engine.RepositoryService)4 Command (org.camunda.bpm.engine.impl.interceptor.Command)4 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)4 InvocationContext (org.camunda.bpm.application.InvocationContext)3 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)3 ProcessApplicationManager (org.camunda.bpm.engine.impl.application.ProcessApplicationManager)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1