use of org.camunda.bpm.engine.delegate.BaseDelegateExecution in project camunda-bpm-platform by camunda.
the class AbstractEventAtomicOperation method execute.
public void execute(T execution) {
CoreModelElement scope = getScope(execution);
List<DelegateListener<? extends BaseDelegateExecution>> listeners = getListeners(scope, execution);
int listenerIndex = execution.getListenerIndex();
if (listenerIndex == 0) {
execution = eventNotificationsStarted(execution);
}
if (!isSkipNotifyListeners(execution)) {
if (listeners.size() > listenerIndex) {
execution.setEventName(getEventName());
execution.setEventSource(scope);
DelegateListener<? extends BaseDelegateExecution> listener = listeners.get(listenerIndex);
try {
execution.setListenerIndex(listenerIndex + 1);
execution.invokeListener(listener);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new PvmException("couldn't execute event listener : " + e.getMessage(), e);
}
execution.performOperationSync(this);
} else {
execution.setListenerIndex(0);
execution.setEventName(null);
execution.setEventSource(null);
eventNotificationsCompleted(execution);
}
} else {
eventNotificationsCompleted(execution);
}
}
use of org.camunda.bpm.engine.delegate.BaseDelegateExecution in project camunda-bpm-platform by camunda.
the class FoxAtomicOperationDeleteCascadeFireActivityEnd method execute.
@Override
public void execute(PvmExecutionImpl execution) {
ScopeImpl scope = getScope(execution);
int executionListenerIndex = execution.getListenerIndex();
List<DelegateListener<? extends BaseDelegateExecution>> executionListeners = scope.getListeners(getEventName());
for (DelegateListener<? extends BaseDelegateExecution> listener : executionListeners) {
execution.setEventName(getEventName());
execution.setEventSource(scope);
try {
execution.invokeListener(listener);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new PvmException("couldn't execute event listener : " + e.getMessage(), e);
}
executionListenerIndex += 1;
execution.setListenerIndex(executionListenerIndex);
}
execution.setListenerIndex(0);
execution.setEventName(null);
execution.setEventSource(null);
eventNotificationsCompleted(execution);
}
use of org.camunda.bpm.engine.delegate.BaseDelegateExecution in project camunda-bpm-platform by camunda.
the class DefaultDelegateInterceptor method handleInvocationInContext.
protected void handleInvocationInContext(final DelegateInvocation invocation) throws Exception {
CommandContext commandContext = Context.getCommandContext();
boolean oldValue = commandContext.isAuthorizationCheckEnabled();
BaseDelegateExecution contextExecution = invocation.getContextExecution();
ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
boolean popExecutionContext = false;
try {
if (!configuration.isAuthorizationEnabledForCustomCode()) {
// the custom code should be executed without authorization
commandContext.disableAuthorizationCheck();
}
try {
commandContext.disableUserOperationLog();
try {
if (contextExecution != null && !isCurrentContextExecution(contextExecution)) {
popExecutionContext = setExecutionContext(contextExecution);
}
invocation.proceed();
} finally {
if (popExecutionContext) {
Context.removeExecutionContext();
}
}
} finally {
commandContext.enableUserOperationLog();
}
} finally {
if (oldValue) {
commandContext.enableAuthorizationCheck();
}
}
}
use of org.camunda.bpm.engine.delegate.BaseDelegateExecution in project camunda-bpm-platform by camunda.
the class DefaultDelegateInterceptor method getProcessApplicationForInvocation.
protected ProcessApplicationReference getProcessApplicationForInvocation(final DelegateInvocation invocation) {
BaseDelegateExecution contextExecution = invocation.getContextExecution();
ResourceDefinitionEntity contextResource = invocation.getContextResource();
if (contextExecution != null) {
return ProcessApplicationContextUtil.getTargetProcessApplication((CoreExecution) contextExecution);
} else if (contextResource != null) {
return ProcessApplicationContextUtil.getTargetProcessApplication(contextResource);
} else {
return null;
}
}
Aggregations