Ejemplo n.º 1
0
        /// <summary>
        ///  @see IFlow#Resume .
        /// </summary>
        /// <param name="stateName"></param>
        /// <param name="executor"></param>
        /// <returns></returns>
        /// <exception cref="FlowExecutionException">&nbsp;</exception>
        public FlowExecution Resume(string stateName, IFlowExecutor executor)
        {
            FlowExecutionStatus status = FlowExecutionStatus.Unkown;
            IState state;

            _stateMap.TryGetValue(stateName, out state);

            if (Logger.IsDebugEnabled)
            {
                Logger.Debug("Resuming state={0} with status={1}", stateName, status);
            }
            StepExecution stepExecution = null;

            String currentStateName = stateName;

            // Terminate if there are no more states
            while (IsFlowContinued(state, status, stepExecution))
            {
                currentStateName = state.GetName();
                try
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug("Handling state={0}", currentStateName);
                    }
                    status        = state.Handle(executor);
                    stepExecution = executor.GetStepExecution();
                }
                catch (FlowExecutionException)
                {
                    executor.Close(new FlowExecution(currentStateName, status));
                    throw;
                }
                catch (Exception e)
                {
                    executor.Close(new FlowExecution(currentStateName, status));
                    throw new FlowExecutionException(
                              string.Format("Ended flow={0} at state={1} with exception", Name, currentStateName), e);
                }
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Completed state={0} with status={1}", currentStateName, status);
                }
                state = NextState(currentStateName, status, stepExecution);
            }
            FlowExecution result = new FlowExecution(currentStateName, status);

            executor.Close(result);
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  @see IFlow#Resume .
        /// </summary>
        /// <param name="stateName"></param>
        /// <param name="executor"></param>
        /// <returns></returns>
        /// <exception cref="FlowExecutionException"></exception>
        public FlowExecution Resume(string stateName, IFlowExecutor executor)
        {
            FlowExecutionStatus status = FlowExecutionStatus.Unkown;
            IState state;
            _stateMap.TryGetValue(stateName, out state);

            if (Logger.IsDebugEnabled)
            {
                Logger.Debug("Resuming state={0} with status={1}", stateName, status);
            }
            StepExecution stepExecution = null;

            String currentStateName = stateName;
            // Terminate if there are no more states
            while (IsFlowContinued(state, status, stepExecution))
            {
                currentStateName = state.GetName();
                try
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug("Handling state={0}", currentStateName);
                    }
                    status = state.Handle(executor);
                    stepExecution = executor.GetStepExecution();
                }
                catch (FlowExecutionException)
                {
                    executor.Close(new FlowExecution(currentStateName, status));
                    throw;
                }
                catch (Exception e)
                {
                    executor.Close(new FlowExecution(currentStateName, status));
                    throw new FlowExecutionException(
                        string.Format("Ended flow={0} at state={1} with exception", Name, currentStateName), e);
                }
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Completed state={0} with status={1}", currentStateName, status);
                }
                state = NextState(currentStateName, status, stepExecution);
            }
            FlowExecution result = new FlowExecution(currentStateName, status);
            executor.Close(result);
            return result;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// @see IFlowExecutor#Close .
 /// </summary>
 /// <param name="result"></param>
 public void Close(FlowExecution result)
 {
     _stepExecutionHolder.Value = null;
 }