Java Code Examples for org.camunda.bpm.engine.impl.context.Context#executeWithinProcessApplication()
The following examples show how to use
org.camunda.bpm.engine.impl.context.Context#executeWithinProcessApplication() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessApplicationEventListenerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void performNotification(final DelegateExecution execution, Callable<Void> notification) throws Exception { final ProcessApplicationReference processApp = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); if (processApp == null) { // ignore silently LOG.noTargetProcessApplicationForExecution(execution); } else { if (ProcessApplicationContextUtil.requiresContextSwitch(processApp)) { // this should not be necessary since context switch is already performed by OperationContext and / or DelegateInterceptor Context.executeWithinProcessApplication(notification, processApp, new InvocationContext(execution)); } else { // context switch already performed notification.call(); } } }
Example 2
Source File: DelegateFormFieldValidator.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public boolean validate(final Object submittedValue, final FormFieldValidatorContext validatorContext) { final DelegateExecution execution = validatorContext.getExecution(); if(shouldPerformPaContextSwitch(validatorContext.getExecution())) { ProcessApplicationReference processApplicationReference = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); return Context.executeWithinProcessApplication(new Callable<Boolean>() { public Boolean call() throws Exception { return doValidate(submittedValue, validatorContext); } }, processApplicationReference, new InvocationContext(execution)); } else { return doValidate(submittedValue, validatorContext); } }
Example 3
Source File: DelegateFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected <T> T performContextSwitch(final Callable<T> callable) { ProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.getTargetProcessApplication(deploymentId); if(targetProcessApplication != null) { return Context.executeWithinProcessApplication(new Callable<T>() { public T call() throws Exception { return doCall(callable); } }, targetProcessApplication); } else { return doCall(callable); } }
Example 4
Source File: CommandContext.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void performOperation(final CmmnAtomicOperation executionOperation, final CaseExecutionEntity execution) { ProcessApplicationReference targetProcessApplication = getTargetProcessApplication(execution); if(requiresContextSwitch(targetProcessApplication)) { Context.executeWithinProcessApplication(new Callable<Void>() { public Void call() throws Exception { performOperation(executionOperation, execution); return null; } }, targetProcessApplication, new InvocationContext(execution)); } else { try { Context.setExecutionContext(execution); LOG.debugExecutingAtomicOperation(executionOperation, execution); executionOperation.execute(execution); } finally { Context.removeExecutionContext(); } } }
Example 5
Source File: VariableInstanceEntity.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public void onImplicitValueUpdate(final TypedValue updatedValue) { // note: this implementation relies on the // behavior that the variable scope // of variable value can never become null ProcessApplicationReference targetProcessApplication = getContextProcessApplication(); if (targetProcessApplication != null) { Context.executeWithinProcessApplication(new Callable<Void>() { @Override public Void call() throws Exception { getVariableScope().setVariableLocal(name, updatedValue); return null; } }, targetProcessApplication, new InvocationContext(getExecution())); } else { if (!isTransient) { getVariableScope().setVariableLocal(name, updatedValue); } } }
Example 6
Source File: DefaultDelegateInterceptor.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void handleInvocation(final DelegateInvocation invocation) throws Exception { final ProcessApplicationReference processApplication = getProcessApplicationForInvocation(invocation); if (processApplication != null && ProcessApplicationContextUtil.requiresContextSwitch(processApplication)) { Context.executeWithinProcessApplication(new Callable<Void>() { @Override public Void call() throws Exception { handleInvocation(invocation); return null; } }, processApplication, new InvocationContext(invocation.getContextExecution())); } else { handleInvocationInContext(invocation); } }
Example 7
Source File: ProcessApplicationContextTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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)); }
Example 8
Source File: CommandInvocationContext.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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... invokeNext(); } } finally { isExecuting = false; } } } }
Example 9
Source File: ProcessApplicationContextInterceptor.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public <T> T execute(final Command<T> command) { ProcessApplicationIdentifier processApplicationIdentifier = ProcessApplicationContextImpl.get(); if (processApplicationIdentifier != null) { // clear the identifier so this interceptor does not apply to nested commands ProcessApplicationContextImpl.clear(); try { ProcessApplicationReference reference = getPaReference(processApplicationIdentifier); return Context.executeWithinProcessApplication(new Callable<T>() { @Override public T call() throws Exception { return next.execute(command); } }, reference); } finally { // restore the identifier for subsequent commands ProcessApplicationContextImpl.set(processApplicationIdentifier); } } else { return next.execute(command); } }
Example 10
Source File: ClassDelegateActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void signal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception { ProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); if(ProcessApplicationContextUtil.requiresContextSwitch(targetProcessApplication)) { Context.executeWithinProcessApplication(new Callable<Void>() { public Void call() throws Exception { signal(execution, signalName, signalData); return null; } }, targetProcessApplication, new InvocationContext(execution)); } else { doSignal(execution, signalName, signalData); } }
Example 11
Source File: CallableElementActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public Object resolveDelegateClass(final ActivityExecution execution) { ProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); if (ProcessApplicationContextUtil.requiresContextSwitch(targetProcessApplication)) { return Context.executeWithinProcessApplication(new Callable<Object>() { @Override public Object call() throws Exception { return resolveDelegateClass(execution); } }, targetProcessApplication, new InvocationContext(execution)); } else { return instantiateDelegateClass(execution); } }
Example 12
Source File: ServiceTaskDelegateExpressionActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void signal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception { ProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); if(ProcessApplicationContextUtil.requiresContextSwitch(targetProcessApplication)) { Context.executeWithinProcessApplication(new Callable<Void>() { public Void call() throws Exception { signal(execution, signalName, signalData); return null; } }, targetProcessApplication, new InvocationContext(execution)); } else { doSignal(execution, signalName, signalData); } }