Ejemplo n.º 1
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="expressionNoAnnotations">expression text witout annotations</param>
        /// <param name="isPattern">is true to indicate this is a pure pattern expression</param>
        /// <param name="dispatchService">for dispatching events to listeners to the statement</param>
        /// <param name="statementLifecycleSvc">handles lifecycle transitions for the statement</param>
        /// <param name="timeLastStateChange">the timestamp the statement was created and started</param>
        /// <param name="isBlockingDispatch">is true if the dispatch to listeners should block to preserve event generation order</param>
        /// <param name="isSpinBlockingDispatch">true to use spin locks blocking to deliver results, as locks are usually uncontended</param>
        /// <param name="msecBlockingTimeout">is the max number of milliseconds of block time</param>
        /// <param name="timeSourceService">time source provider</param>
        /// <param name="statementMetadata">statement metadata</param>
        /// <param name="userObject">the application define user object associated to each statement, if supplied</param>
        /// <param name="statementContext">the statement service context</param>
        /// <param name="isFailed">indicator to start in failed state</param>
        /// <param name="nameProvided">true to indicate a statement name has been provided and is not a system-generated name</param>
        public EPStatementImpl(
            String expressionNoAnnotations,
            bool isPattern,
            DispatchService dispatchService,
            StatementLifecycleSvc statementLifecycleSvc,
            long timeLastStateChange,
            bool isBlockingDispatch,
            bool isSpinBlockingDispatch,
            long msecBlockingTimeout,
            TimeSourceService timeSourceService,
            StatementMetadata statementMetadata,
            Object userObject,
            StatementContext statementContext,
            bool isFailed,
            bool nameProvided)
        {
            _statementLifecycleSvc = statementLifecycleSvc;
            _statementListenerSet  = new EPStatementListenerSet();

            IsPattern = isPattern;
            ExpressionNoAnnotations = expressionNoAnnotations;
            StatementContext        = statementContext;
            IsNameProvided          = nameProvided;

            if (isBlockingDispatch)
            {
                if (isSpinBlockingDispatch)
                {
                    _dispatchChildView = new UpdateDispatchViewBlockingSpin(
                        statementContext.StatementResultService,
                        dispatchService, msecBlockingTimeout,
                        timeSourceService,
                        statementContext.ThreadLocalManager);
                }
                else
                {
                    _dispatchChildView = new UpdateDispatchViewBlockingWait(
                        statementContext.StatementResultService,
                        dispatchService, msecBlockingTimeout,
                        statementContext.ThreadLocalManager);
                }
            }
            else
            {
                _dispatchChildView = new UpdateDispatchViewNonBlocking(
                    statementContext.StatementResultService,
                    dispatchService,
                    statementContext.ThreadLocalManager);
            }

            State = !isFailed ? EPStatementState.STOPPED : EPStatementState.FAILED;
            TimeLastStateChange = timeLastStateChange;
            StatementMetadata   = statementMetadata;
            UserObject          = userObject;
            statementContext.StatementResultService.SetUpdateListeners(_statementListenerSet, false);
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     if (State == EPStatementState.DESTROYED)
     {
         throw new IllegalStateException("Statement already destroyed");
     }
     _statementLifecycleSvc.Destroy(StatementContext.StatementId);
     _parentView            = null;
     EventType              = null;
     _dispatchChildView     = null;
     _statementLifecycleSvc = null;
 }