Ejemplo n.º 1
0
        protected internal override void instantiateScopes(MigratingScopeInstance ancestorScopeInstance, MigratingScopeInstanceBranch executionBranch, IList <ScopeImpl> scopesToInstantiate)
        {
            if (scopesToInstantiate.Count == 0)
            {
                return;
            }

            ExecutionEntity ancestorScopeExecution = ancestorScopeInstance.resolveRepresentativeExecution();

            ExecutionEntity parentExecution = ancestorScopeExecution;

            foreach (ScopeImpl scope in scopesToInstantiate)
            {
                ExecutionEntity compensationScopeExecution = parentExecution.createExecution();
                compensationScopeExecution.Scope      = true;
                compensationScopeExecution.EventScope = true;

                compensationScopeExecution.setActivity((PvmActivity)scope);
                compensationScopeExecution.Active = false;
                compensationScopeExecution.activityInstanceStarting();
                compensationScopeExecution.enterActivityInstance();

                EventSubscriptionEntity eventSubscription = EventSubscriptionEntity.createAndInsert(parentExecution, EventType.COMPENSATE, (ActivityImpl)scope);
                eventSubscription.Configuration = compensationScopeExecution.Id;

                executionBranch.visited(new MigratingEventScopeInstance(eventSubscription, compensationScopeExecution, scope));

                parentExecution = compensationScopeExecution;
            }
        }
Ejemplo n.º 2
0
        protected internal override ICollection <MigrationContext> nextElements()
        {
            ICollection <MigrationContext> nextElements = new LinkedList <MigrationContext>();

            MigrationContext currentElement = CurrentElement;

            // continue migration for non-leaf instances (i.e. scopes)
            if (currentElement.processElementInstance is MigratingScopeInstance)
            {
                // Child instances share the same scope instance branch;
                // This ensures "once-per-parent" instantiation semantics,
                // i.e. if a new parent scope is added to more than one child, all those children
                // will share the same new parent instance.
                // By changing the way how the branches are created here, it should be possible
                // to implement other strategies, e.g. "once-per-child" semantics
                MigratingScopeInstanceBranch childrenScopeBranch             = currentElement.scopeInstanceBranch.copy();
                MigratingScopeInstanceBranch childrenCompensationScopeBranch = currentElement.scopeInstanceBranch.copy();

                MigratingScopeInstance scopeInstance = (MigratingScopeInstance)currentElement.processElementInstance;

                childrenScopeBranch.visited(scopeInstance);
                childrenCompensationScopeBranch.visited(scopeInstance);

                foreach (MigratingProcessElementInstance child in scopeInstance.Children)
                {
                    MigratingScopeInstanceBranch instanceBranch = null;

                    // compensation and non-compensation scopes cannot share the same scope instance branch
                    // e.g. when adding a sub process, we want to create a new activity instance as well
                    // as a new event scope instance for that sub process
                    if (child is MigratingEventScopeInstance || child is MigratingCompensationEventSubscriptionInstance)
                    {
                        instanceBranch = childrenCompensationScopeBranch;
                    }
                    else
                    {
                        instanceBranch = childrenScopeBranch;
                    }
                    nextElements.Add(new MigrationContext(child, instanceBranch));
                }
            }

            return(nextElements);
        }
Ejemplo n.º 3
0
        protected internal override void instantiateScopes(MigratingScopeInstance ancestorScopeInstance, MigratingScopeInstanceBranch executionBranch, IList <ScopeImpl> scopesToInstantiate)
        {
            if (scopesToInstantiate.Count == 0)
            {
                return;
            }

            // must always be an activity instance
            MigratingActivityInstance ancestorActivityInstance = (MigratingActivityInstance)ancestorScopeInstance;

            ExecutionEntity newParentExecution = ancestorActivityInstance.createAttachableExecution();

            IDictionary <PvmActivity, PvmExecutionImpl> createdExecutions = newParentExecution.instantiateScopes((System.Collections.IList)scopesToInstantiate, skipCustomListeners, skipIoMappings);

            foreach (ScopeImpl scope in scopesToInstantiate)
            {
                ExecutionEntity createdExecution = (ExecutionEntity)createdExecutions[scope];
                createdExecution.setActivity(null);
                createdExecution.Active = false;
                executionBranch.visited(new MigratingActivityInstance(scope, createdExecution));
            }
        }