Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: @Override public <T> T execute(final Command<T> command)
        public override T execute <T>(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 CallableAnonymousInnerClass(this, command)
                                                                   , reference));
                }
                finally
                {
                    // restore the identifier for subsequent commands
                    ProcessApplicationContextImpl.set(processApplicationIdentifier);
                }
            }
            else
            {
                return(next.execute(command));
            }
        }
Ejemplo n.º 2
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();
                }
            }
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void handleInvocation(final DelegateInvocation invocation) throws Exception
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        public virtual void handleInvocation(DelegateInvocation invocation)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.application.ProcessApplicationReference processApplication = getProcessApplicationForInvocation(invocation);
            ProcessApplicationReference processApplication = getProcessApplicationForInvocation(invocation);

            if (processApplication != null && ProcessApplicationContextUtil.requiresContextSwitch(processApplication))
            {
                Context.executeWithinProcessApplication(new CallableAnonymousInnerClass(this, invocation)
                                                        , processApplication, new InvocationContext(invocation.ContextExecution));
            }
            else
            {
                handleInvocationInContext(invocation);
            }
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") public void testExecuteWithInvocationContext() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testExecuteWithInvocationContext()
        {
            // given a process application which extends the default one
            // - using a spy for verify the invocations
            TestApplicationWithoutEngine processApplication          = spy(pa);
            ProcessApplicationReference  processApplicationReference = mock(typeof(ProcessApplicationReference));

            when(processApplicationReference.ProcessApplication).thenReturn(processApplication);

            // when execute with context
            InvocationContext invocationContext = new InvocationContext(mock(typeof(BaseDelegateExecution)));

            Context.executeWithinProcessApplication(mock(typeof(Callable)), processApplicationReference, invocationContext);

            // then the execute method should be invoked with context
            verify(processApplication).execute(any(typeof(Callable)), eq(invocationContext));
            // and forward to call to the default execute method
            verify(processApplication).execute(any(typeof(Callable)));
        }
Ejemplo n.º 6
0
 public ScriptEngine execute(CommandContext commandContext)
 {
     return(Context.executeWithinProcessApplication(new CallableAnonymousInnerClass(this)
                                                    , processApplication.Reference));
 }