public EventBean Copy(EventBean theEvent)
        {
            DecoratingEventBean decorated           = (DecoratingEventBean)theEvent;
            EventBean           decoratedUnderlying = decorated.UnderlyingEvent;
            EventBean           copiedUnderlying    = _underlyingCopyMethod.Copy(decoratedUnderlying);

            if (copiedUnderlying == null)
            {
                return(null);
            }
            return(_eventAdapterService.AdapterForTypedWrapper(copiedUnderlying, decorated.DecoratingProperties, _wrapperEventType));
        }
Exemplo n.º 2
0
        public EventBean Copy(EventBean theEvent)
        {
            var decorated = (DecoratingEventBean) theEvent;
            var decoratedUnderlying = decorated.UnderlyingEvent;
            var copiedUnderlying = underlyingCopyMethod.Copy(decoratedUnderlying);
            if (copiedUnderlying == null) {
                return null;
            }

            IDictionary<string, object> copiedMap = new Dictionary<string, object>(decorated.DecoratingProperties);
            return eventAdapterService.AdapterForTypedWrapper(copiedUnderlying, copiedMap, wrapperEventType);
        }
Exemplo n.º 3
0
        public EventBean Copy(EventBean theEvent)
        {
            DecoratingEventBean decorated           = (DecoratingEventBean)theEvent;
            EventBean           decoratedUnderlying = decorated.UnderlyingEvent;
            EventBean           copiedUnderlying    = _underlyingCopyMethod.Copy(decoratedUnderlying);

            if (copiedUnderlying == null)
            {
                return(null);
            }
            IDictionary <String, Object> copiedMap = new Dictionary <String, Object>(decorated.DecoratingProperties);

            return(_eventAdapterService.AdapterForTypedWrapper(copiedUnderlying, copiedMap, _wrapperEventType));
        }
Exemplo n.º 4
0
        public EventBean Copy(EventBean theEvent)
        {
            var decorated = (DecoratingEventBean) theEvent;
            var decoratedUnderlying = decorated.UnderlyingEvent;
            var copiedUnderlying = underlyingCopyMethod.Copy(decoratedUnderlying);
            if (copiedUnderlying == null) {
                return null;
            }

            return eventAdapterService.AdapterForTypedWrapper(
                copiedUnderlying,
                decorated.DecoratingProperties,
                wrapperEventType);
        }
Exemplo n.º 5
0
        public EventBean UpdateWCopy(EventBean matchingEvent, EventBean[] eventsPerStream, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QInfraUpdate(matchingEvent, eventsPerStream, _updateItems.Length, true);
            }

            EventBean copy = _copyMethod.Copy(matchingEvent);

            eventsPerStream[0] = copy;
            eventsPerStream[2] = matchingEvent; // initial value

            UpdateInternal(eventsPerStream, exprEvaluatorContext, copy);

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AInfraUpdate(copy);
            }
            return(copy);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Pre-proces the event.
        /// </summary>
        /// <param name="theEvent">to pre-process</param>
        /// <param name="exprEvaluatorContext">expression evaluation context</param>
        /// <returns>
        /// processed event
        /// </returns>
        public EventBean Process(EventBean theEvent, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (_empty)
            {
                return(theEvent);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QUpdateIStream(_entries);
            }

            EventBean oldEvent        = theEvent;
            bool      haveCloned      = false;
            var       eventsPerStream = new EventBean[1];

            eventsPerStream[0] = theEvent;
            InternalEventRouterEntry lastEntry = null;

            for (int i = 0; i < _entries.Length; i++)
            {
                InternalEventRouterEntry entry = _entries[i];
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QUpdateIStreamApply(i, entry);
                }

                ExprEvaluator whereClause = entry.OptionalWhereClause;
                if (whereClause != null)
                {
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().QUpdateIStreamApplyWhere();
                    }

                    var result = whereClause.Evaluate(new EvaluateParams(eventsPerStream, true, exprEvaluatorContext));
                    if ((result == null) || (false.Equals(result)))
                    {
                        if (InstrumentationHelper.ENABLED)
                        {
                            InstrumentationHelper.Get().AUpdateIStreamApplyWhere((bool?)result);
                        }
                        if (InstrumentationHelper.ENABLED)
                        {
                            InstrumentationHelper.Get().AUpdateIStreamApply(null, false);
                        }

                        continue;
                    }
                    if (InstrumentationHelper.ENABLED)
                    {
                        InstrumentationHelper.Get().AUpdateIStreamApplyWhere(true);
                    }
                }

                if (entry.IsDrop)
                {
                    return(null);
                }

                // before applying the changes, indicate to last-entries output view
                if (lastEntry != null)
                {
                    InternalRoutePreprocessView view = lastEntry.OutputView;
                    if (view.IsIndicate)
                    {
                        EventBean copied = _copyMethod.Copy(theEvent);
                        view.Indicate(copied, oldEvent);
                        oldEvent = copied;
                    }
                    else
                    {
                        if (_entries[i].OutputView.IsIndicate)
                        {
                            oldEvent = _copyMethod.Copy(theEvent);
                        }
                    }
                }

                // copy event for the first Update that applies
                if (!haveCloned)
                {
                    EventBean copiedEvent = _copyMethod.Copy(theEvent);
                    if (copiedEvent == null)
                    {
                        Log.Warn("Event of type " + theEvent.EventType.Name + " could not be copied");
                        if (InstrumentationHelper.ENABLED)
                        {
                            InstrumentationHelper.Get().AUpdateIStreamApply(null, false);
                        }
                        return(null);
                    }
                    haveCloned         = true;
                    eventsPerStream[0] = copiedEvent;
                    theEvent           = copiedEvent;
                }

                Apply(theEvent, eventsPerStream, entry, exprEvaluatorContext);
                lastEntry = entry;
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AUpdateIStreamApply(theEvent, true);
                }
            }

            if (lastEntry != null)
            {
                InternalRoutePreprocessView view = lastEntry.OutputView;
                if (view.IsIndicate)
                {
                    view.Indicate(theEvent, oldEvent);
                }
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AUpdateIStream(theEvent, haveCloned);
            }
            return(theEvent);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Pre-proces the event.
        /// </summary>
        /// <param name="theEvent">to pre-process</param>
        /// <param name="exprEvaluatorContext">expression evaluation context</param>
        /// <param name="instrumentation">instrumentation</param>
        /// <returns>processed event</returns>
        public EventBean Process(
            EventBean theEvent,
            ExprEvaluatorContext exprEvaluatorContext,
            InstrumentationCommon instrumentation)
        {
            if (empty) {
                return theEvent;
            }

            instrumentation.QUpdateIStream(entries);

            var oldEvent = theEvent;
            var haveCloned = false;
            var eventsPerStream = new EventBean[1];
            eventsPerStream[0] = theEvent;
            InternalEventRouterEntry lastEntry = null;

            for (var i = 0; i < entries.Length; i++) {
                var entry = entries[i];
                instrumentation.QUpdateIStreamApply(i, entry);

                var whereClause = entry.OptionalWhereClause;
                if (whereClause != null) {
                    instrumentation.QUpdateIStreamApplyWhere();
                    var result = whereClause.Evaluate(eventsPerStream, true, exprEvaluatorContext);
                    if (result == null || false.Equals(result)) {
                        instrumentation.AUpdateIStreamApplyWhere(false);
                        instrumentation.AUpdateIStreamApply(null, false);
                        continue;
                    }

                    instrumentation.AUpdateIStreamApplyWhere(true);
                }

                if (entry.IsDrop) {
                    instrumentation.AUpdateIStreamApply(null, false);
                    return null;
                }

                // before applying the changes, indicate to last-entries output view
                if (lastEntry != null) {
                    var view = lastEntry.OutputView;
                    if (view.IsIndicate) {
                        var copied = copyMethod.Copy(theEvent);
                        view.Indicate(copied, oldEvent);
                        oldEvent = copied;
                    }
                    else {
                        if (entries[i].OutputView.IsIndicate) {
                            oldEvent = copyMethod.Copy(theEvent);
                        }
                    }
                }

                // copy event for the first update that applies
                if (!haveCloned) {
                    var copiedEvent = copyMethod.Copy(theEvent);
                    if (copiedEvent == null) {
                        Log.Warn("Event of type " + theEvent.EventType.Name + " could not be copied");
                        instrumentation.AUpdateIStreamApply(null, false);
                        return null;
                    }

                    haveCloned = true;
                    eventsPerStream[0] = copiedEvent;
                    theEvent = copiedEvent;
                }

                Apply(theEvent, eventsPerStream, entry, exprEvaluatorContext, instrumentation);
                lastEntry = entry;

                instrumentation.AUpdateIStreamApply(theEvent, true);
            }

            if (lastEntry != null) {
                var view = lastEntry.OutputView;
                if (view.IsIndicate) {
                    view.Indicate(theEvent, oldEvent);
                }
            }

            instrumentation.AUpdateIStream(theEvent, haveCloned);
            return theEvent;
        }