コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void handleInvocationInContext(final DelegateInvocation invocation) throws Exception
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        protected internal virtual void handleInvocationInContext(DelegateInvocation invocation)
        {
            CommandContext        commandContext = Context.CommandContext;
            bool                  wasAuthorizationCheckEnabled = commandContext.AuthorizationCheckEnabled;
            bool                  wasUserOperationLogEnabled   = commandContext.UserOperationLogEnabled;
            BaseDelegateExecution contextExecution             = invocation.ContextExecution;

            ProcessEngineConfigurationImpl configuration = Context.ProcessEngineConfiguration;

            bool popExecutionContext = false;

            try
            {
                if (!configuration.AuthorizationEnabledForCustomCode)
                {
                    // 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
                {
                    if (wasUserOperationLogEnabled)
                    {
                        commandContext.enableUserOperationLog();
                    }
                }
            }
            finally
            {
                if (wasAuthorizationCheckEnabled)
                {
                    commandContext.enableAuthorizationCheck();
                }
            }
        }
コード例 #2
0
        public virtual void execute(BpmnStackTrace stackTrace)
        {
            if (operation != org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.ACTIVITY_START_CANCEL_SCOPE && operation != org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.ACTIVITY_START_INTERRUPT_SCOPE && operation != org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.ACTIVITY_START_CONCURRENT && operation != org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.DELETE_CASCADE)
            {
                // execution might be replaced in the meantime:
                ExecutionEntity replacedBy = execution.ReplacedBy;
                if (replacedBy != null)
                {
                    execution = replacedBy;
                }
            }

            //execution was canceled for example via terminate end event
            if (execution.Canceled && (operation == org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.TRANSITION_NOTIFY_LISTENER_END || operation == org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.ACTIVITY_NOTIFY_LISTENER_END))
            {
                return;
            }

            // execution might have ended in the meanwhile
            if (execution.Ended && (operation == org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.TRANSITION_NOTIFY_LISTENER_TAKE || operation == org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation_Fields.ACTIVITY_START_CREATE_SCOPE))
            {
                return;
            }

            ProcessApplicationReference currentPa = Context.CurrentProcessApplication;

            if (currentPa != null)
            {
                applicationContextName = currentPa.Name;
            }
            activityId   = execution.ActivityId;
            activityName = execution.CurrentActivityName;
            stackTrace.add(this);

            try
            {
                Context.ExecutionContext = execution;
                if (!performAsync)
                {
                    LOG.debugExecutingAtomicOperation(operation, execution);
                    operation.execute(execution);
                }
                else
                {
                    execution.scheduleAtomicOperationAsync(this);
                }
            }
            finally
            {
                Context.removeExecutionContext();
            }
        }