Exemplo n.º 1
0
        public override void Transfer(
            IntSeqKey path,
            bool transferChildContexts,
            AgentInstanceTransferServices xfer)
        {
            var factory = KeyedFactory;
            ContextControllerFilterEntry[] filters = keyedSvc.MgmtGetFilters(path);
            for (int i = 0; i < factory.KeyedSpec.Items.Length; i++) {
                ContextControllerDetailKeyedItem item = factory.KeyedSpec.Items[i];
                filters[i].Transfer(item.FilterSpecActivatable, xfer);
            }

            if (factory.KeyedSpec.OptionalTermination != null) {
                keyedSvc.KeyVisitEntry(path, entry => entry.TerminationCondition.Transfer(xfer));
            }

            if (!transferChildContexts) {
                return;
            }

            keyedSvc.KeyVisit(
                path,
                (
                    partitionKey,
                    subpathId) => {
                    realization.TransferRecursive(path, subpathId, this, xfer);
                });
        }
 public ContextControllerKeyedFilterEntryNoInit(
     ContextControllerKeyedImpl callback,
     IntSeqKey controllerPath,
     object[] parentPartitionKeys,
     ContextControllerDetailKeyedItem item)
     : base(callback, controllerPath, item, parentPartitionKeys)
 {
     Start(item.FilterSpecActivatable);
 }
Exemplo n.º 3
0
 private ContextControllerFilterEntry ActivateFilterWithInit(
     ContextConditionDescriptorFilter filter,
     ContextControllerDetailKeyedItem item,
     EventBean optionalTriggeringEvent,
     IntSeqKey controllerPath,
     object[] parentPartitionKeys)
 {
     return new ContextControllerKeyedFilterEntryWInit(this, controllerPath, item, parentPartitionKeys, filter);
 }
Exemplo n.º 4
0
 public ContextControllerKeyedFilterEntry(
     ContextControllerKeyedImpl callback,
     IntSeqKey controllerPath,
     ContextControllerDetailKeyedItem item,
     object[] parentPartitionKeys)
 {
     this.callback = callback;
     this.controllerPath = controllerPath;
     this.item = item;
     this.parentPartitionKeys = parentPartitionKeys;
 }
 public ContextControllerKeyedFilterEntryWInit(
     ContextControllerKeyedImpl callback,
     IntSeqKey controllerPath,
     ContextControllerDetailKeyedItem item,
     object[] parentPartitionKeys,
     ContextConditionDescriptorFilter initCond)
     : base(callback, controllerPath, item, parentPartitionKeys)
 {
     this.initCond = initCond;
     Start(initCond.FilterSpecActivatable);
 }
Exemplo n.º 6
0
        public static ContextControllerDetailKeyedItem FindInitMatchingKey(
            ContextControllerDetailKeyedItem[] items,
            ContextConditionDescriptorFilter init)
        {
            ContextControllerDetailKeyedItem found = null;
            foreach (var item in items) {
                if (item.FilterSpecActivatable.FilterForEventType == init.FilterSpecActivatable.FilterForEventType) {
                    found = item;
                    break;
                }
            }

            if (found == null) {
                throw new ArgumentException(
                    "Failed to find matching partition for type '" + init.FilterSpecActivatable.FilterForEventType);
            }

            return found;
        }
Exemplo n.º 7
0
        private ContextControllerFilterEntry ActivateFilterNoInit(
            ContextControllerDetailKeyedItem item,
            EventBean optionalTriggeringEvent,
            IntSeqKey controllerPath,
            object[] parentPartitionKeys)
        {
            var callback = new ContextControllerKeyedFilterEntryNoInit(this, controllerPath, parentPartitionKeys, item);
            if (optionalTriggeringEvent != null) {
                var match = AgentInstanceUtil.EvaluateFilterForStatement(
                    optionalTriggeringEvent,
                    realization.AgentInstanceContextCreate,
                    callback.FilterHandle);

                if (match) {
                    callback.MatchFound(optionalTriggeringEvent, null);
                }
            }

            return callback;
        }
Exemplo n.º 8
0
        public void MatchFound(
            ContextControllerDetailKeyedItem item,
            EventBean theEvent,
            IntSeqKey controllerPath,
            string optionalInitCondAsName)
        {
            if (controllerPath.Length != Factory.FactoryEnv.NestingLevel - 1) {
                throw new IllegalStateException("Unrecognized controller path");
            }

            var getterKey = item.Getter.Get(theEvent);
            var exists = keyedSvc.KeyHasSeen(controllerPath, getterKey);
            if (exists || theEvent == LastTerminatingEvent) {
                // if all-matches is more than one, the termination has also fired
                return;
            }

            LastTerminatingEvent = null;

            var partitionKey = getterKey;
            if (KeyedFactory.KeyedSpec.HasAsName) {
                partitionKey = new ContextControllerKeyedPartitionKeyWInit(
                    getterKey,
                    optionalInitCondAsName,
                    optionalInitCondAsName == null ? null : theEvent);
            }

            var parentPartitionKeys = keyedSvc.MgmtGetPartitionKeys(controllerPath);

            // get next subpath id
            var subpathId = keyedSvc.MgmtGetIncSubpath(controllerPath);

            // instantiate
            var result = realization.ContextPartitionInstantiate(
                controllerPath,
                subpathId,
                this,
                theEvent,
                null,
                parentPartitionKeys,
                partitionKey);
            var subpathIdOrCPId = result.SubpathOrCPId;

            // handle termination filter
            ContextControllerConditionNonHA terminationCondition = null;
            if (KeyedFactory.KeyedSpec.OptionalTermination != null) {
                var conditionPath = controllerPath.AddToEnd(subpathIdOrCPId);
                terminationCondition = ActivateTermination(
                    theEvent,
                    parentPartitionKeys,
                    partitionKey,
                    conditionPath,
                    optionalInitCondAsName);

                foreach (var agentInstance in result.AgentInstances) {
                    agentInstance.AgentInstanceContext.EpStatementAgentInstanceHandle.FilterFaultHandler =
                        ContextControllerWTerminationFilterFaultHandler.INSTANCE;
                }
            }

            keyedSvc.KeyAdd(controllerPath, getterKey, subpathIdOrCPId, terminationCondition);

            // update the filter version for this handle
            var filterVersionAfterStart = realization.AgentInstanceContextCreate.FilterService.FiltersVersion;
            realization.AgentInstanceContextCreate.EpStatementAgentInstanceHandle.StatementFilterVersion
                .StmtFilterVersion = filterVersionAfterStart;
        }
Exemplo n.º 9
0
        public static FilterValueSetParam[][] GetAddendumFilters(
            object getterKey,
            FilterSpecActivatable filtersSpec,
            ContextControllerDetailKeyed keyedSpec,
            bool includePartition,
            ContextControllerStatementDesc optionalStatementDesc,
            AgentInstanceContext agentInstanceContext)
        {
            // determine whether create-named-window
            var isCreateWindow = optionalStatementDesc != null &&
                                 optionalStatementDesc.Lightweight.StatementContext.StatementInformationals
                                     .StatementType ==
                                 StatementType.CREATE_WINDOW;
            ContextControllerDetailKeyedItem foundPartition = null;

            if (!isCreateWindow) {
                foreach (var partitionItem in keyedSpec.Items) {
                    var typeOrSubtype = EventTypeUtility.IsTypeOrSubTypeOf(
                        filtersSpec.FilterForEventType,
                        partitionItem.FilterSpecActivatable.FilterForEventType);
                    if (typeOrSubtype) {
                        foundPartition = partitionItem;
                        break;
                    }
                }
            }
            else {
                var factory = (StatementAgentInstanceFactoryCreateNW) optionalStatementDesc.Lightweight.StatementContext
                    .StatementAIFactoryProvider
                    .Factory;
                var declaredAsName = factory.AsEventTypeName;
                foreach (var partitionItem in keyedSpec.Items) {
                    if (partitionItem.FilterSpecActivatable.FilterForEventType.Name.Equals(declaredAsName)) {
                        foundPartition = partitionItem;
                        break;
                    }
                }
            }

            if (foundPartition == null) {
                return null;
            }

            var lookupables = foundPartition.Lookupables;
            var addendumFilters = new FilterValueSetParam[lookupables.Length];
            if (lookupables.Length == 1) {
                addendumFilters[0] = GetFilterMayEqualOrNull(lookupables[0], getterKey);
            }
            else {
                var keys = getterKey is HashableMultiKey ? ((HashableMultiKey) getterKey).Keys : (object[]) getterKey;
                for (var i = 0; i < lookupables.Length; i++) {
                    addendumFilters[i] = GetFilterMayEqualOrNull(lookupables[i], keys[i]);
                }
            }

            var addendum = new FilterValueSetParam[1][];
            addendum[0] = addendumFilters;

            var partitionFilters = foundPartition.FilterSpecActivatable.GetValueSet(
                null,
                null,
                agentInstanceContext,
                agentInstanceContext.StatementContextFilterEvalEnv);
            if (partitionFilters != null && includePartition) {
                addendum = FilterAddendumUtil.AddAddendum(partitionFilters, addendum[0]);
            }

            return addendum;
        }