예제 #1
0
 public VariableMetaData(
     string variableName,
     string variableModuleName,
     NameAccessModifier variableVisibility,
     string optionalContextName,
     NameAccessModifier? optionalContextVisibility,
     string optionalContextModule,
     Type type,
     EventType eventType,
     bool preconfigured,
     bool constant,
     bool compileTimeConstant,
     object valueWhenAvailable,
     bool createdByCurrentModule)
 {
     VariableName = variableName;
     VariableModuleName = variableModuleName;
     VariableVisibility = variableVisibility;
     OptionalContextName = optionalContextName;
     OptionalContextVisibility = optionalContextVisibility;
     OptionalContextModule = optionalContextModule;
     Type = type;
     EventType = eventType;
     IsPreconfigured = preconfigured;
     IsConstant = constant;
     IsCompileTimeConstant = compileTimeConstant;
     ValueWhenAvailable = valueWhenAvailable;
     IsCreatedByCurrentModule = createdByCurrentModule;
 }
예제 #2
0
        /// <summary>
        /// NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="expressionName">name</param>
        /// <param name="visibility">visibility</param>
        /// <param name="optionalModuleName">module name</param>
        /// <param name="services">services</param>
        /// <returns>deployment id</returns>
        public static string ResolveDeploymentId(
            string expressionName,
            NameAccessModifier visibility,
            string optionalModuleName,
            EPStatementInitServices services)
        {
            string deploymentId;
            if (visibility == NameAccessModifier.PRECONFIGURED) {
                deploymentId = null;
            }
            else if (visibility == NameAccessModifier.PRIVATE) {
                deploymentId = services.DeploymentId;
            }
            else if (visibility == NameAccessModifier.PUBLIC) {
                deploymentId = services.ExprDeclaredPathRegistry.GetDeploymentId(expressionName, optionalModuleName);
                if (deploymentId == null) {
                    throw new EPException("Failed to resolve path expression '" + expressionName + "'");
                }
            }
            else {
                throw new ArgumentException("Unrecognized visibility " + visibility);
            }

            return deploymentId;
        }
예제 #3
0
        private static string ResolveDeploymentId(
            string tableName,
            NameAccessModifier visibility,
            string optionalModuleName,
            EPStatementInitServices services)
        {
            string deploymentId;
            switch (visibility) {
                case NameAccessModifier.PRIVATE:
                    deploymentId = services.DeploymentId;
                    break;

                case NameAccessModifier.PUBLIC:
                case NameAccessModifier.INTERNAL:
                {
                    deploymentId = services.NamedWindowPathRegistry.GetDeploymentId(tableName, optionalModuleName);
                    if (deploymentId == null) {
                        throw new EPException("Failed to resolve path named window '" + tableName + "'");
                    }

                    break;
                }

                default:
                    throw new ArgumentException("Unrecognized visibility " + visibility);
            }

            return deploymentId;
        }
예제 #4
0
 private TableMetaData(
     string tableName,
     string tableModuleName,
     NameAccessModifier tableVisibility,
     string optionalContextName,
     NameAccessModifier? optionalContextVisibility,
     string optionalContextModule,
     EventType internalEventType,
     EventType publicEventType,
     string[] keyColumns,
     Type[] keyTypes,
     int[] keyColNums,
     IDictionary<string, TableMetadataColumn> columns,
     int numMethodAggs,
     IndexMultiKey keyIndexMultiKey,
     EventTableIndexMetadata indexMetadata)
 {
     TableName = tableName;
     TableModuleName = tableModuleName;
     TableVisibility = tableVisibility;
     OptionalContextName = optionalContextName;
     OptionalContextVisibility = optionalContextVisibility;
     OptionalContextModule = optionalContextModule;
     InternalEventType = internalEventType;
     PublicEventType = publicEventType;
     KeyColumns = keyColumns;
     KeyTypes = keyTypes;
     KeyColNums = keyColNums;
     Columns = columns;
     NumMethodAggs = numMethodAggs;
     KeyIndexMultiKey = keyIndexMultiKey;
     IndexMetadata = indexMetadata;
 }
예제 #5
0
        public EventTypeIdPair ComputeIdFromWrapped(
            NameAccessModifier visibility,
            string innerName,
            EventTypeMetadata metadataWrapper)
        {
            if (visibility == TRANSIENT || visibility == PRIVATE) {
                return new EventTypeIdPair(metadataWrapper.EventTypeIdPair.PublicId, CRC32Util.ComputeCRC32(innerName));
            }

            return new EventTypeIdPair(CRC32Util.ComputeCRC32(innerName), -1);
        }
예제 #6
0
 public ContextMetaData(
     string contextName,
     string contextModuleName,
     NameAccessModifier contextVisibility,
     EventType eventType,
     ContextControllerPortableInfo[] validationInfos)
 {
     ContextName = contextName;
     ContextModuleName = contextModuleName;
     ContextVisibility = contextVisibility;
     EventType = eventType;
     ValidationInfos = validationInfos;
 }
 public ContextCompileTimeDescriptor(
     string contextName,
     string contextModuleName,
     NameAccessModifier contextVisibility,
     ContextPropertyRegistry contextPropertyRegistry,
     ContextControllerPortableInfo[] validationInfos)
 {
     ContextName = contextName;
     ContextModuleName = contextModuleName;
     ContextVisibility = contextVisibility;
     ContextPropertyRegistry = contextPropertyRegistry;
     ValidationInfos = validationInfos;
 }
예제 #8
0
        public static Table ResolveTable(
            string tableName,
            NameAccessModifier visibility,
            string optionalModuleName,
            EPStatementInitServices services)
        {
            string deploymentId = ResolveDeploymentId(tableName, visibility, optionalModuleName, services);
            Table table = services.TableManagementService.GetTable(deploymentId, tableName);
            if (table == null) {
                throw new EPException("Failed to resolve table '" + tableName + "'");
            }

            return table;
        }
예제 #9
0
        public static Variable ResolveVariable(
            string variableName,
            NameAccessModifier visibility,
            string optionalModuleName,
            EPStatementInitServices services)
        {
            var deploymentId = ResolveDeploymentId(variableName, visibility, optionalModuleName, services);
            var variable = services.VariableManagementService.GetVariableMetaData(deploymentId, variableName);
            if (variable == null) {
                throw new EPException("Failed to resolve variable '" + variableName + "'");
            }

            return variable;
        }
예제 #10
0
 public IndexCompileTimeKey(
     string infraModuleName,
     string infraName,
     NameAccessModifier visibility,
     bool namedWindow,
     string indexName,
     string indexModuleName)
 {
     InfraModuleName = infraModuleName;
     InfraName = infraName;
     Visibility = visibility;
     IsNamedWindow = namedWindow;
     IndexName = indexName;
     IndexModuleName = indexModuleName;
 }
예제 #11
0
        public static NamedWindow ResolveNamedWindow(
            string namedWindowName,
            NameAccessModifier visibility,
            string optionalModuleName,
            EPStatementInitServices services)
        {
            string deploymentId = ResolveDeploymentId(namedWindowName, visibility, optionalModuleName, services);
            NamedWindow namedWindow =
                services.NamedWindowManagementService.GetNamedWindow(deploymentId, namedWindowName);
            if (namedWindow == null) {
                throw new EPException("Failed to resolve named window '" + namedWindowName + "'");
            }

            return namedWindow;
        }
예제 #12
0
        /// <summary>
        /// Returns true for a public and protected and false for all others
        /// </summary>
        /// <returns>indicator</returns>
        public static bool IsNonPrivateNonTransient(this NameAccessModifier value)
        {
            switch (value)
            {
            case NameAccessModifier.TRANSIENT:
            case NameAccessModifier.PRIVATE:
            case NameAccessModifier.PRECONFIGURED:
                return(false);

            case NameAccessModifier.INTERNAL:
            case NameAccessModifier.PUBLIC:
                return(true);
            }

            throw new ArgumentException("invalid value", nameof(value));
        }
예제 #13
0
        /// <summary>
        /// Returns indicator whether the object is visible.
        /// <para>Always false if the object is private or transient.</para>
        /// <para>Always true if the object is public or preconfigured.</para>
        /// <para>For protected the module name must match</para>
        /// </summary>
        /// <param name="objectVisibility">object visibility</param>
        /// <param name="objectModuleName">object module name</param>
        /// <param name="importModuleName">my module name</param>
        /// <returns>indicator</returns>
        public static bool Visible(
            NameAccessModifier objectVisibility,
            string objectModuleName,
            string importModuleName)
        {
            if (objectVisibility.IsPrivateOrTransient())
            {
                return(false);
            }

            if (objectVisibility == NameAccessModifier.INTERNAL)
            {
                return(CompareModuleName(objectModuleName, importModuleName));
            }

            return(true);
        }
예제 #14
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="name">event type name</param>
 /// <param name="moduleName">
 ///     module name that originated the event type or null if not provided or if the event type is
 ///     preconfigured
 /// </param>
 /// <param name="typeClass">information on the originator or use of the event type</param>
 /// <param name="applicationType">provides the type of the underlying</param>
 /// <param name="accessModifier">the access modifier defining how the event type is visible to other modules</param>
 /// <param name="busModifier">
 ///     the bus modifier defining how the event type is visible to applications calling send-event
 ///     methods
 /// </param>
 /// <param name="isPropertyAgnostic">
 ///     whether the type is property-agnostic (false for most typed, true for a type that
 ///     allows any property name)
 /// </param>
 /// <param name="eventTypeIdPair">the type id pair</param>
 public EventTypeMetadata(
     string name,
     string moduleName,
     EventTypeTypeClass typeClass,
     EventTypeApplicationType applicationType,
     NameAccessModifier accessModifier,
     EventTypeBusModifier busModifier,
     bool isPropertyAgnostic,
     EventTypeIdPair eventTypeIdPair)
 {
     Name = name;
     ModuleName = moduleName;
     TypeClass = typeClass;
     ApplicationType = applicationType;
     AccessModifier = accessModifier;
     BusModifier = busModifier;
     IsPropertyAgnostic = isPropertyAgnostic;
     EventTypeIdPair = eventTypeIdPair;
 }
예제 #15
0
 public static VariableMetaData CompileVariable(
     String variableName,
     String variableModuleName,
     NameAccessModifier variableVisibility,
     String optionalContextName,
     NameAccessModifier? optionalContextVisibility,
     String optionalModuleName,
     ClassIdentifierWArray variableType,
     bool isConstant,
     bool compileTimeConstant,
     Object initializationValue,
     ImportService importService,
     ExtensionClass extensionClass,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
     BeanEventTypeFactory beanEventTypeFactory)
 {
     try {
         return GetTypeInfo(
             variableName,
             variableModuleName,
             variableVisibility,
             optionalContextName,
             optionalContextVisibility,
             optionalModuleName,
             variableType,
             false,
             isConstant,
             compileTimeConstant,
             initializationValue,
             importService,
             extensionClass,
             eventBeanTypedEventFactory,
             eventTypeRepositoryPreconfigured,
             beanEventTypeFactory);
     }
     catch (VariableTypeException t) {
         throw new ExprValidationException(t.Message, t);
     }
     catch (Exception t) {
         throw new ExprValidationException("Failed to compile variable '" + variableName + "': " + t.Message, t);
     }
 }
예제 #16
0
        public static IDictionary<int, VariableReader> ResolveVariableReaderPerCP(
            string variableName,
            NameAccessModifier visibility,
            string optionalModuleName,
            string optionalContextName,
            EPStatementInitServices services)
        {
            if (optionalContextName == null) {
                throw new ArgumentException("No context name");
            }

            var deploymentId = ResolveDeploymentId(variableName, visibility, optionalModuleName, services);
            IDictionary<int, VariableReader> reader =
                services.VariableManagementService.GetReadersPerCP(deploymentId, variableName);
            if (reader == null) {
                throw new EPException("Failed to resolve variable '" + variableName + "'");
            }

            return reader;
        }
예제 #17
0
        private static string ResolveDeploymentId(
            string tableName,
            NameAccessModifier visibility,
            string optionalModuleName,
            EPStatementInitServices services)
        {
            string deploymentId;
            if (visibility == NameAccessModifier.PRIVATE) {
                deploymentId = services.DeploymentId;
            }
            else if (visibility == NameAccessModifier.PUBLIC || visibility == NameAccessModifier.INTERNAL) {
                deploymentId = services.TablePathRegistry.GetDeploymentId(tableName, optionalModuleName);
                if (deploymentId == null) {
                    throw new EPException("Failed to resolve path table '" + tableName + "'");
                }
            }
            else {
                throw new ArgumentException("Unrecognized visibility " + visibility);
            }

            return deploymentId;
        }
예제 #18
0
        public static VariableReader ResolveVariableReader(
            string variableName,
            NameAccessModifier visibility,
            string optionalModuleName,
            string optionalContextName,
            EPStatementInitServices services)
        {
            if (optionalContextName != null) {
                throw new ArgumentException("Expected null context name");
            }

            var deploymentId = ResolveDeploymentId(variableName, visibility, optionalModuleName, services);
            var reader = services.VariableManagementService.GetReader(
                deploymentId,
                variableName,
                DEFAULT_AGENT_INSTANCE_ID);
            if (reader == null) {
                throw new EPException("Failed to resolve variable '" + variableName + "'");
            }

            return reader;
        }
예제 #19
0
        private static VariableMetaData GetTypeInfo(
            string variableName,
            string variableModuleName,
            NameAccessModifier variableVisibility,
            string optionalContextName,
            NameAccessModifier? optionalContextVisibility,
            string optionalContextModule,
            ClassIdentifierWArray variableTypeWArray,
            bool preconfigured,
            bool constant,
            bool compileTimeConstant,
            object valueAsProvided,
            ImportService importService,
            ExtensionClass extensionClass,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            // Determine the variable type
            var primitiveType = TypeHelper.GetPrimitiveTypeForName(variableTypeWArray.ClassIdentifier);
            var type = TypeHelper.GetTypeForSimpleName(variableTypeWArray.ClassIdentifier).GetBoxedType();
            Type arrayType = null;
            EventType eventType = null;
            if (type == null) {
                if (variableTypeWArray.ClassIdentifier.Equals("object", StringComparison.InvariantCultureIgnoreCase)) {
                    type = TypeHelper.GetArrayType(typeof(object), variableTypeWArray.ArrayDimensions);
                }

                if (type == null) {
                    eventType = eventTypeRepositoryPreconfigured.GetTypeByName(variableTypeWArray.ClassIdentifier);
                    if (eventType != null) {
                        type = eventType.UnderlyingType;
                    }
                }

                ImportException lastException = null;
                if (type == null) {
                    try {
                        type = importService.ResolveClass(variableTypeWArray.ClassIdentifier, false, extensionClass);
                        type = TypeHelper.GetArrayType(type, variableTypeWArray.ArrayDimensions);
                    }
                    catch (ImportException e) {
                        Log.Debug("Not found '" + type + "': " + e.Message, e);
                        lastException = e;
                        // expected
                    }
                }

                if (type == null) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' is not a recognized type",
                        lastException);
                }

                if (variableTypeWArray.ArrayDimensions > 0 && eventType != null) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' cannot be declared as an array type as it is an event type",
                        lastException);
                }
            }
            else {
                if (variableTypeWArray.ArrayDimensions > 0) {
                    if (variableTypeWArray.IsArrayOfPrimitive) {
                        if (primitiveType == null) {
                            throw new VariableTypeException(
                                "Cannot create variable '" +
                                variableName +
                                "', type '" +
                                variableTypeWArray.ClassIdentifier +
                                "' is not a primitive type");
                        }

                        arrayType = TypeHelper.GetArrayType(primitiveType, variableTypeWArray.ArrayDimensions);
                    }
                    else {
                        arrayType = TypeHelper.GetArrayType(type, variableTypeWArray.ArrayDimensions);
                    }
                }
            }

            if (eventType == null &&
                !type.IsBuiltinDataType() &&
                type != typeof(object) &&
                !type.IsArray &&
                !type.IsEnum) {
                if (variableTypeWArray.ArrayDimensions > 0) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' cannot be declared as an array, only scalar types can be array");
                }

                eventType = beanEventTypeFactory.GetCreateBeanType(type, false);
            }

            if (arrayType != null) {
                type = arrayType;
            }

            var coerced = GetCoercedValue(valueAsProvided, eventType, variableName, type, eventBeanTypedEventFactory);
            return new VariableMetaData(
                variableName,
                variableModuleName,
                variableVisibility,
                optionalContextName,
                optionalContextVisibility,
                optionalContextModule,
                type,
                eventType,
                preconfigured,
                constant,
                compileTimeConstant,
                coerced,
                true);
        }
예제 #20
0
 public ExpressionScriptProvided WithVisibility(NameAccessModifier visibility)
 {
     Visibility = visibility;
     return this;
 }