コード例 #1
0
        /// <summary>
        /// Returns the statement by the given statement name. Returns null if a statement
        /// of that name has not been created, or if the statement by that name has been
        /// destroyed.
        /// </summary>
        /// <param name="name">is the statement name to return the statement for</param>
        /// <returns>
        /// statement for the given name, or null if no such started or stopped statement
        /// exists
        /// </returns>
        public EPStatement GetStatement(string name)
        {
            lock (_statementTable)
            {
                var statementWrapper = _statementTable.Get(name);
                if ((statementWrapper != null) && statementWrapper.IsAlive)
                {
                    return(statementWrapper.Target);
                }
            }

            using (var wrapper = CreateControlManager())
            {
                try
                {
                    return(WithExceptionHandling(
                               delegate
                    {
                        var controlManager = wrapper.Channel;
                        var statement = controlManager.GetStatement(_instanceId, name);
                        var statementWrapper = new CatalystStatement(_adapter, statement);
                        BindStatement(statementWrapper);

                        return statementWrapper;
                    }));
                }
                catch (ItemNotFoundException)
                {
                    return(null);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates and starts a prepared statement.
        /// <para/>
        /// The statement name is optimally a unique name. If a statement of the same name
        /// has already been created, the engine assigns a postfix to create a unique
        /// statement name.
        /// <para/>
        /// Accepts an application defined user data object associated with the statement.
        /// The <em>user object</em> is a single, unnamed field that is stored with every
        /// statement. Applications may put arbitrary objects in this field or a null value.
        /// </summary>
        /// <param name="prepared">is the prepared statement for which all substitution values have been provided</param>
        /// <param name="statementName">is the name to assign to the statement for use in managing the statement</param>
        /// <param name="userObject">is the application-defined user object</param>
        /// <returns>
        /// EPStatement to poll data from or to add listeners to
        /// </returns>
        /// <throws>EPException when the prepared statement was not valid</throws>
        public EPStatement Create(EPPreparedStatement prepared, string statementName, object userObject)
        {
            if (prepared == null)
            {
                throw new ArgumentNullException("prepared");
            }

            var cprepared = prepared as CatalystPreparedStatement;

            if (cprepared == null)
            {
                throw new ArgumentException("prepared statement was of incorrect type", "prepared");
            }

            using (var wrapper = CreateControlManager())
            {
                return(WithExceptionHandling(
                           delegate
                {
                    var controlManager = wrapper.Channel;
                    var statementArgs = new StatementCreationArgs();
                    statementArgs.PreparedStatementId = cprepared.Id;
                    statementArgs.StatementName = statementName;
                    statementArgs.StatementText = null;

                    var statement = controlManager.CreatePrepared(_instanceId, statementArgs);
                    var statementWrapper = new CatalystStatement(_adapter, statement, userObject);
                    BindStatement(statementWrapper);

                    return statementWrapper;
                }));
            }
        }
コード例 #3
0
        /// <summary>
        /// Create and starts an event pattern statement for the expressing string passed.
        /// <para/>
        /// The engine assigns a unique name to the statement.
        /// </summary>
        /// <param name="onExpression">must follow the documented syntax for pattern statements</param>
        /// <returns>
        /// EPStatement to poll data from or to add listeners to
        /// </returns>
        /// <throws>EPException when the expression was not valid</throws>
        public EPStatement CreatePattern(string onExpression)
        {
            using (var wrapper = CreateControlManager())
            {
                return(WithExceptionHandling(
                           delegate
                {
                    var controlManager = wrapper.Channel;
                    var statementArgs = new StatementCreationArgs();
                    statementArgs.StatementText = onExpression;

                    var statement = controlManager.CreatePattern(_instanceId, statementArgs);
                    var statementWrapper = new CatalystStatement(_adapter, statement);
                    BindStatement(statementWrapper);

                    return statementWrapper;
                }));
            }
        }
コード例 #4
0
        /// <summary>
        /// Create and starts an EPL statement.
        /// <para/>
        /// Accepts an application defined user data object associated with the statement.
        /// The <em>user object</em> is a single, unnamed field that is stored with every
        /// statement. Applications may put arbitrary objects in this field or a null value.
        /// </summary>
        /// <param name="eplStatement">is the query language statement</param>
        /// <param name="userObject">is the application-defined user object</param>
        /// <returns>
        /// EPStatement to poll data from or to add listeners to
        /// </returns>
        /// <throws>EPException when the expression was not valid</throws>
        public EPStatement CreateEPL(string eplStatement, object userObject)
        {
            using (var wrapper = CreateControlManager())
            {
                return(WithExceptionHandling(
                           delegate
                {
                    var controlManager = wrapper.Channel;
                    var statementArgs = new StatementCreationArgs();
                    statementArgs.StatementText = eplStatement;

                    var statement = controlManager.CreateEPL(_instanceId, statementArgs);
                    var statementWrapper = new CatalystStatement(_adapter, statement, userObject);
                    BindStatement(statementWrapper);

                    return statementWrapper;
                }));
            }
        }
コード例 #5
0
 private void BindStatement(CatalystStatement statement)
 {
     lock (_statementTable) {
         _statementTable[statement.Id] = new WeakReference <CatalystStatement>(statement);
     }
 }