Exemple #1
0
        public AvroEventType(
            EventTypeMetadata metadata,
            Schema avroSchema,
            string startTimestampPropertyName,
            string endTimestampPropertyName,
            EventType[] optionalSuperTypes,
            ISet<EventType> deepSupertypes,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeAvroHandler eventTypeAvroHandler)
        {
            Metadata = metadata;
            _avroSchema = avroSchema;
            _optionalSuperTypes = optionalSuperTypes;
            _deepSupertypes = deepSupertypes ?? new EmptySet<EventType>();
            _propertyItems = new LinkedHashMap<string, PropertySetDescriptorItem>();
            _eventBeanTypedEventFactory = eventBeanTypedEventFactory;
            _eventTypeAvroHandler = eventTypeAvroHandler;

            Init();

            var desc = EventTypeUtility.ValidatedDetermineTimestampProps(
                this,
                startTimestampPropertyName,
                endTimestampPropertyName,
                optionalSuperTypes);
            StartTimestampPropertyName = desc.Start;
            EndTimestampPropertyName = desc.End;
        }
 public EventTypeResolvingBeanFactoryImpl(
     EventTypeRepository eventTypeRepository,
     EventTypeAvroHandler avroHandler)
 {
     this.eventTypeRepository = eventTypeRepository;
     this.avroHandler = avroHandler;
 }
 public EventTypeCollectorImpl(
     IContainer container,
     IDictionary<string, EventType> moduleEventTypes,
     BeanEventTypeFactory beanEventTypeFactory,
     ClassLoader classLoader,
     EventTypeFactory eventTypeFactory,
     BeanEventTypeStemService beanEventTypeStemService,
     EventTypeNameResolver eventTypeNameResolver,
     XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory,
     EventTypeAvroHandler eventTypeAvroHandler,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     ImportService importService)
 {
     _container = container;
     _moduleEventTypes = moduleEventTypes;
     _beanEventTypeFactory = beanEventTypeFactory;
     _classLoader = classLoader;
     _eventTypeFactory = eventTypeFactory;
     _beanEventTypeStemService = beanEventTypeStemService;
     _eventTypeNameResolver = eventTypeNameResolver;
     _xmlFragmentEventTypeFactory = xmlFragmentEventTypeFactory;
     _eventTypeAvroHandler = eventTypeAvroHandler;
     _eventBeanTypedEventFactory = eventBeanTypedEventFactory;
     _importService = importService;
 }
 private static void BuildAvroType(
     EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
     string eventTypeName,
     ConfigurationCommonEventTypeAvro config,
     EventTypeAvroHandler eventTypeAvroHandler,
     EventBeanTypedEventFactory eventBeanTypedEventFactory)
 {
     var metadata = new EventTypeMetadata(
         eventTypeName,
         null,
         EventTypeTypeClass.APPLICATION,
         EventTypeApplicationType.AVRO,
         NameAccessModifier.PRECONFIGURED,
         EventTypeBusModifier.NONBUS,
         false,
         new EventTypeIdPair(CRC32Util.ComputeCRC32(eventTypeName), -1));
     var avroSuperTypes = EventTypeUtility.GetSuperTypesDepthFirst(
         config.SuperTypes,
         EventUnderlyingType.AVRO,
         eventTypeRepositoryPreconfigured);
     var newEventType = eventTypeAvroHandler.NewEventTypeFromSchema(
         metadata,
         eventBeanTypedEventFactory,
         config,
         avroSuperTypes.First,
         avroSuperTypes.Second);
     eventTypeRepositoryPreconfigured.AddType(newEventType);
 }
Exemple #5
0
        public static EventTypeAvroHandler Resolve(
            ImportService importService,
            ConfigurationCommonEventTypeMeta.AvroSettingsConfig avroSettings,
            string handlerClass)
        {
            // Make services that depend on snapshot config entries
            EventTypeAvroHandler avroHandler = EventTypeAvroHandlerUnsupported.INSTANCE;
            if (avroSettings.IsEnableAvro) {
                try {
                    avroHandler = TypeHelper.Instantiate<EventTypeAvroHandler>(
                        handlerClass,
                        importService.ClassForNameProvider);
                }
                catch (Exception t) {
                    Log.Debug(
                        "Avro provider {} not instantiated, not enabling Avro support: {}",
                        handlerClass,
                        t.Message);
                }

                try {
                    avroHandler.Init(avroSettings, importService);
                }
                catch (Exception t) {
                    throw new ConfigurationException("Failed to initialize Esper-Avro: " + t.Message, t);
                }
            }

            return avroHandler;
        }
        public static SelectExprProcessorForge GetInsertUnderlyingJoinWildcard(
            EventType eventType,
            string[] streamNames,
            EventType[] streamTypes,
            ImportServiceCompileTime importService,
            string statementName,
            EventTypeAvroHandler eventTypeAvroHandler)
        {
            var writableProps = EventTypeUtility.GetWriteableProperties(eventType, false, false);
            var isEligible = CheckEligible(eventType, writableProps, false);
            if (!isEligible) {
                return null;
            }

            try {
                return InitializeJoinWildcardInternal(
                    eventType,
                    writableProps,
                    streamNames,
                    streamTypes,
                    statementName,
                    importService,
                    eventTypeAvroHandler);
            }
            catch (ExprValidationException ex) {
                if (!(eventType is BeanEventType)) {
                    throw;
                }

                // Try constructor injection
                try {
                    var forges = new ExprForge[streamTypes.Length];
                    var resultTypes = new object[streamTypes.Length];
                    for (var i = 0; i < streamTypes.Length; i++) {
                        forges[i] = new ExprForgeJoinWildcard(i, streamTypes[i].UnderlyingType);
                        resultTypes[i] = forges[i].EvaluationType;
                    }

                    return InitializeCtorInjection(
                        (BeanEventType) eventType,
                        forges,
                        resultTypes,
                        importService);
                }
                catch (ExprValidationException) {
                    if (writableProps.IsEmpty()) {
                        throw;
                    }

                    throw ex;
                }
            }
        }
 public SelectExprForgeContext(
     ExprForge[] exprForges,
     string[] columnNames,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     EventType[] eventTypes,
     EventTypeAvroHandler eventTypeAvroHandler)
 {
     ExprForges = exprForges;
     ColumnNames = columnNames;
     EventBeanTypedEventFactory = eventBeanTypedEventFactory;
     EventTypes = eventTypes;
     EventTypeAvroHandler = eventTypeAvroHandler;
 }
        internal static FragmentEventType GetFragmentEventTypeForField(
            Schema fieldSchema,
            string moduleName,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeAvroHandler eventTypeAvroHandler,
            AvroEventTypeFragmentTypeCache fragmentTypeCache)
        {
            Schema recordSchema;
            var indexed = false;
            if (fieldSchema.Tag == Schema.Type.Record) {
                recordSchema = fieldSchema;
            }
            else if (fieldSchema.Tag == Schema.Type.Array &&
                     fieldSchema.AsArraySchema().ItemSchema.Tag == Schema.Type.Record) {
                recordSchema = fieldSchema.AsArraySchema().ItemSchema;
                indexed = true;
            }
            else {
                return null;
            }

            var cached = fragmentTypeCache.Get(recordSchema.Name);
            if (cached != null) {
                return new FragmentEventType(cached, indexed, false);
            }

            var metadata = new EventTypeMetadata(
                recordSchema.Name,
                moduleName,
                EventTypeTypeClass.STREAM,
                EventTypeApplicationType.AVRO,
                NameAccessModifier.TRANSIENT,
                EventTypeBusModifier.NONBUS,
                false,
                EventTypeIdPair.Unassigned());
            var config = new ConfigurationCommonEventTypeAvro();
            config.AvroSchema = recordSchema;

            var fragmentType = eventTypeAvroHandler.NewEventTypeFromSchema(
                metadata,
                eventBeanTypedEventFactory,
                config,
                null,
                null);

            fragmentTypeCache.Add(recordSchema.Name, fragmentType);
            return new FragmentEventType(fragmentType, indexed, false);
        }
 public static void BuildAvroTypes(
     EventTypeRepositoryImpl repo,
     IDictionary<string, ConfigurationCommonEventTypeAvro> eventTypesAvro,
     EventTypeAvroHandler eventTypeAvroHandler,
     EventBeanTypedEventFactory eventBeanTypedEventFactory)
 {
     foreach (var entry in eventTypesAvro) {
         if (repo.GetTypeByName(entry.Key) != null) {
             continue;
         }
         
         BuildAvroType(
             repo,
             entry.Key,
             entry.Value,
             eventTypeAvroHandler,
             eventBeanTypedEventFactory);
     }
 }
        internal static FragmentEventType GetFragmentType(
            Schema schema,
            string propertyName,
            string moduleName,
            IDictionary<string, PropertySetDescriptorItem> propertyItems,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeAvroHandler eventTypeAvroHandler,
            AvroEventTypeFragmentTypeCache fragmentTypeCache)
        {
            var unescapePropName = StringValue.UnescapeDot(propertyName);
            var item = propertyItems.Get(unescapePropName);
            if (item != null) {
                return item.FragmentEventType;
            }

            var property = PropertyParser.ParseAndWalkLaxToSimple(propertyName);
            var desc = AvroFieldUtil.FieldForProperty(schema, property);
            if (desc == null) {
                return null;
            }

            if (desc.IsDynamic) {
                return null;
            }

            var fieldSchemaByAccess = desc.Field.Schema;
            if (desc.IsAccessedByIndex) {
                fieldSchemaByAccess = fieldSchemaByAccess.AsArraySchema().ItemSchema;
            }

            return GetFragmentEventTypeForField(
                fieldSchemaByAccess,
                moduleName,
                eventBeanTypedEventFactory,
                eventTypeAvroHandler,
                fragmentTypeCache);
        }
        public static EventBeanUpdateHelperForge Make(
            string updatedWindowOrTableName,
            EventTypeSPI eventTypeSPI,
            IList <OnTriggerSetAssignment> assignments,
            string updatedAlias,
            EventType optionalTriggeringEventType,
            bool isCopyOnWrite,
            string statementName,
            EventTypeAvroHandler avroHandler)
        {
            IList <EventBeanUpdateItemForge> updateItems = new List <EventBeanUpdateItemForge>();
            IList <string> properties = new List <string>();

            TypeWidenerCustomizer typeWidenerCustomizer = avroHandler.GetTypeWidenerCustomizer(eventTypeSPI);

            for (int i = 0; i < assignments.Count; i++)
            {
                OnTriggerSetAssignment desc       = assignments[i];
                ExprAssignment         assignment = desc.Validated;
                if (assignment == null)
                {
                    throw new IllegalStateException("Assignment has not been validated");
                }

                try {
                    EventBeanUpdateItemForge updateItem;
                    if (assignment is ExprAssignmentStraight)
                    {
                        ExprAssignmentStraight straight = (ExprAssignmentStraight)assignment;

                        // handle assignment "property = value"
                        if (straight.Lhs is ExprAssignmentLHSIdent)
                        {
                            ExprAssignmentLHSIdent ident = (ExprAssignmentLHSIdent)straight.Lhs;

                            string propertyName = ident.Ident;
                            EventPropertyDescriptor writableProperty = eventTypeSPI.GetWritableProperty(propertyName);

                            // check assignment to indexed or mapped property
                            if (writableProperty == null)
                            {
                                Pair <string, EventPropertyDescriptor> nameWriteablePair = CheckIndexedOrMappedProp(
                                    propertyName,
                                    updatedWindowOrTableName,
                                    updatedAlias,
                                    eventTypeSPI);
                                propertyName     = nameWriteablePair.First;
                                writableProperty = nameWriteablePair.Second;
                            }

                            ExprNode  rhsExpr             = straight.Rhs;
                            ExprForge rhsForge            = rhsExpr.Forge;
                            EventPropertyWriterSPI writer = eventTypeSPI.GetWriter(propertyName);
                            bool notNullableField         = writableProperty.PropertyType.IsPrimitive;

                            properties.Add(propertyName);
                            TypeWidenerSPI widener;
                            try {
                                widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(rhsExpr),
                                    rhsForge.EvaluationType,
                                    writableProperty.PropertyType,
                                    propertyName,
                                    false,
                                    typeWidenerCustomizer,
                                    statementName);
                            }
                            catch (TypeWidenerException ex) {
                                throw new ExprValidationException(ex.Message, ex);
                            }

                            // check event type assignment
                            bool useUntypedAssignment = false;
                            bool useTriggeringEvent   = false;
                            if (optionalTriggeringEventType != null)
                            {
                                // handle RHS is ident node
                                if (rhsExpr is ExprIdentNode)
                                {
                                    ExprIdentNode     node        = (ExprIdentNode)rhsExpr;
                                    FragmentEventType fragmentRHS = optionalTriggeringEventType.GetFragmentType(node.ResolvedPropertyName);
                                    FragmentEventType fragmentLHS = eventTypeSPI.GetFragmentType(propertyName);
                                    if (fragmentRHS != null && fragmentLHS != null)
                                    {
                                        if (!EventTypeUtility.IsTypeOrSubTypeOf(fragmentRHS.FragmentType, fragmentLHS.FragmentType))
                                        {
                                            throw MakeEventTypeMismatch(propertyName, fragmentLHS.FragmentType, fragmentRHS.FragmentType);
                                        }
                                    }

                                    // we don't need to cast if it is a self-assignment and LHS is an event and target needs no writer
                                    if (node.StreamId == 0 && fragmentLHS != null && eventTypeSPI is BaseNestableEventType)
                                    {
                                        useUntypedAssignment = true;
                                    }
                                }

                                // handle RHS is a stream of the triggering event itself
                                if (rhsExpr is ExprStreamUnderlyingNode)
                                {
                                    ExprStreamUnderlyingNode und = (ExprStreamUnderlyingNode)rhsExpr;
                                    if (und.StreamId == 1)
                                    {
                                        FragmentEventType fragmentLHS = eventTypeSPI.GetFragmentType(propertyName);
                                        if (fragmentLHS != null &&
                                            optionalTriggeringEventType is BaseNestableEventType &&
                                            !EventTypeUtility.IsTypeOrSubTypeOf(optionalTriggeringEventType, fragmentLHS.FragmentType))
                                        {
                                            throw MakeEventTypeMismatch(propertyName, fragmentLHS.FragmentType, optionalTriggeringEventType);
                                        }

                                        // we use the event itself for assignment and target needs no writer
                                        if (eventTypeSPI is BaseNestableEventType)
                                        {
                                            useUntypedAssignment = true;
                                            useTriggeringEvent   = true;
                                        }
                                    }
                                }
                            }

                            updateItem = new EventBeanUpdateItemForge(
                                rhsForge,
                                propertyName,
                                writer,
                                notNullableField,
                                widener,
                                useUntypedAssignment,
                                useTriggeringEvent,
                                null);
                        }
                        else if (straight.Lhs is ExprAssignmentLHSArrayElement)
                        {
                            // handle "property[expr] = value"
                            ExprAssignmentLHSArrayElement arrayElementLHS = (ExprAssignmentLHSArrayElement)straight.Lhs;
                            string   arrayPropertyName = arrayElementLHS.Ident;
                            ExprNode rhs            = straight.Rhs;
                            Type     evaluationType = rhs.Forge.EvaluationType;
                            Type     propertyType   = eventTypeSPI.GetPropertyType(arrayPropertyName);
                            if (!eventTypeSPI.IsProperty(arrayPropertyName))
                            {
                                throw new ExprValidationException("Property '" + arrayPropertyName + "' could not be found");
                            }

                            if (propertyType == null || !propertyType.IsArray)
                            {
                                throw new ExprValidationException("Property '" + arrayPropertyName + "' is not an array");
                            }

                            EventPropertyGetterSPI getter = eventTypeSPI.GetGetterSPI(arrayPropertyName);
                            Type componentType            = propertyType.GetElementType();
                            if (!TypeHelper.IsAssignmentCompatible(evaluationType, componentType))
                            {
                                throw new ExprValidationException(
                                          "Invalid assignment to property '" +
                                          arrayPropertyName +
                                          "' component type '" +
                                          componentType.CleanName() +
                                          "' from expression returning '" +
                                          evaluationType.CleanName() +
                                          "'");
                            }

                            TypeWidenerSPI widener;
                            try {
                                widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(straight.Rhs),
                                    evaluationType,
                                    componentType,
                                    arrayPropertyName,
                                    false,
                                    typeWidenerCustomizer,
                                    statementName);
                            }
                            catch (TypeWidenerException ex) {
                                throw new ExprValidationException(ex.Message, ex);
                            }

                            EventBeanUpdateItemArray arrayInfo = new EventBeanUpdateItemArray(
                                arrayPropertyName,
                                arrayElementLHS.IndexExpression,
                                propertyType,
                                getter);
                            updateItem = new EventBeanUpdateItemForge(
                                rhs.Forge,
                                arrayPropertyName,
                                null,
                                false,
                                widener,
                                false,
                                false,
                                arrayInfo);
                        }
                        else
                        {
                            throw new IllegalStateException("Unrecognized LHS assignment " + straight);
                        }
                    }
                    else if (assignment is ExprAssignmentCurly)
                    {
                        // handle non-assignment, i.e. UDF or other expression
                        ExprAssignmentCurly dot = (ExprAssignmentCurly)assignment;
                        updateItem = new EventBeanUpdateItemForge(
                            dot.Expression.Forge,
                            null,
                            null,
                            false,
                            null,
                            false,
                            false,
                            null);
                    }
                    else
                    {
                        throw new IllegalStateException("Unrecognized assignment " + assignment);
                    }

                    updateItems.Add(updateItem);
                }
                catch (ExprValidationException ex) {
                    throw new ExprValidationException(
                              "Failed to validate assignment expression '" +
                              ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(assignment.OriginalExpression) +
                              "': " +
                              ex.Message,
                              ex);
                }
            }

            // copy-on-write is the default event semantics as events are immutable
            EventBeanCopyMethodForge copyMethod;

            if (isCopyOnWrite)
            {
                // obtain copy method
                List <string> propertiesUniqueList = new List <string>(new HashSet <string>(properties));
                string[]      propertiesArray      = propertiesUniqueList.ToArray();
                copyMethod = eventTypeSPI.GetCopyMethodForge(propertiesArray);
                if (copyMethod == null)
                {
                    throw new ExprValidationException("Event type does not support event bean copy");
                }
            }
            else
            {
                // for in-place update, determine assignment expressions to use "initial" to access prior-change values
                // the copy-method is optional
                copyMethod = null;
                ISet <string> propertiesInitialValue = DeterminePropertiesInitialValue(assignments);
                if (!propertiesInitialValue.IsEmpty())
                {
                    string[] propertiesInitialValueArray = propertiesInitialValue.ToArray();
                    copyMethod = eventTypeSPI.GetCopyMethodForge(propertiesInitialValueArray);
                }
            }

            EventBeanUpdateItemForge[] updateItemsArray = updateItems.ToArray();
            return(new EventBeanUpdateHelperForge(eventTypeSPI, copyMethod, updateItemsArray));
        }
 public StatementContextRuntimeServices(
     IContainer container,
     ContextManagementService contextManagementService,
     ContextServiceFactory contextServiceFactory,
     DatabaseConfigServiceRuntime databaseConfigService,
     DataFlowFilterServiceAdapter dataFlowFilterServiceAdapter,
     EPDataFlowServiceImpl dataflowService,
     string runtimeURI,
     INamingContext runtimeEnvContext,
     ImportServiceRuntime importServiceRuntime,
     RuntimeSettingsService runtimeSettingsService,
     RuntimeExtensionServices runtimeExtensionServices,
     object epRuntime,
     EPRenderEventService epRuntimeRenderEvent,
     EventServiceSendEventCommon eventServiceSendEventInternal,
     EPRuntimeEventProcessWrapped epRuntimeEventProcessWrapped,
     EventBeanService eventBeanService,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     EventTableIndexService eventTableIndexService,
     EventTypeAvroHandler eventTypeAvroHandler,
     PathRegistry<string, EventType> eventTypePathRegistry,
     EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
     EventTypeResolvingBeanFactory eventTypeResolvingBeanFactory,
     ExceptionHandlingService exceptionHandlingService,
     ExpressionResultCacheService expressionResultCacheService,
     FilterBooleanExpressionFactory filterBooleanExpressionFactory,
     FilterSharedBoolExprRepository filterSharedBoolExprRepository,
     FilterSharedLookupableRepository filterSharedLookupableRepository,
     HistoricalDataCacheFactory historicalDataCacheFactory,
     InternalEventRouter internalEventRouter,
     MetricReportingService metricReportingService,
     NamedWindowConsumerManagementService namedWindowConsumerManagementService,
     NamedWindowManagementService namedWindowManagementService,
     PathRegistry<string, ContextMetaData> pathContextRegistry,
     PathRegistry<string, NamedWindowMetaData> pathNamedWindowRegistry,
     RowRecogStateRepoFactory rowRecogStateRepoFactory,
     ResultSetProcessorHelperFactory resultSetProcessorHelperFactory,
     StatementAgentInstanceLockFactory statementAgentInstanceLockFactory,
     StatementResourceHolderBuilder statementResourceHolderBuilder,
     TableExprEvaluatorContext tableExprEvaluatorContext,
     TableManagementService tableManagementService,
     VariableManagementService variableManagementService,
     ViewFactoryService viewFactoryService,
     ViewServicePreviousFactory viewServicePreviousFactory)
 {
     Container = container;
     ContextManagementService = contextManagementService;
     ContextServiceFactory = contextServiceFactory;
     DatabaseConfigService = databaseConfigService;
     DataFlowFilterServiceAdapter = dataFlowFilterServiceAdapter;
     DataflowService = dataflowService;
     RuntimeURI = runtimeURI;
     RuntimeEnvContext = runtimeEnvContext;
     ImportServiceRuntime = importServiceRuntime;
     RuntimeSettingsService = runtimeSettingsService;
     RuntimeExtensionServices = runtimeExtensionServices;
     Runtime = epRuntime;
     EPRuntimeRenderEvent = epRuntimeRenderEvent;
     EventServiceSendEventInternal = eventServiceSendEventInternal;
     EPRuntimeEventProcessWrapped = epRuntimeEventProcessWrapped;
     EventBeanService = eventBeanService;
     EventBeanTypedEventFactory = eventBeanTypedEventFactory;
     EventTableIndexService = eventTableIndexService;
     EventTypeAvroHandler = eventTypeAvroHandler;
     EventTypePathRegistry = eventTypePathRegistry;
     EventTypeRepositoryPreconfigured = eventTypeRepositoryPreconfigured;
     EventTypeResolvingBeanFactory = eventTypeResolvingBeanFactory;
     ExceptionHandlingService = exceptionHandlingService;
     ExpressionResultCacheService = expressionResultCacheService;
     FilterBooleanExpressionFactory = filterBooleanExpressionFactory;
     FilterSharedBoolExprRepository = filterSharedBoolExprRepository;
     FilterSharedLookupableRepository = filterSharedLookupableRepository;
     HistoricalDataCacheFactory = historicalDataCacheFactory;
     InternalEventRouter = internalEventRouter;
     MetricReportingService = metricReportingService;
     NamedWindowConsumerManagementService = namedWindowConsumerManagementService;
     NamedWindowManagementService = namedWindowManagementService;
     PathContextRegistry = pathContextRegistry;
     PathNamedWindowRegistry = pathNamedWindowRegistry;
     RowRecogStateRepoFactory = rowRecogStateRepoFactory;
     ResultSetProcessorHelperFactory = resultSetProcessorHelperFactory;
     StatementAgentInstanceLockFactory = statementAgentInstanceLockFactory;
     StatementResourceHolderBuilder = statementResourceHolderBuilder;
     TableExprEvaluatorContext = tableExprEvaluatorContext;
     TableManagementService = tableManagementService;
     VariableManagementService = variableManagementService;
     ViewFactoryService = viewFactoryService;
     ViewServicePreviousFactory = viewServicePreviousFactory;
 }
        private static SelectExprProcessorForge InitializeJoinWildcardInternal(
            EventType eventType,
            ISet<WriteablePropertyDescriptor> writables,
            string[] streamNames,
            EventType[] streamTypes,
            string statementName,
            ImportServiceCompileTime importService,
            EventTypeAvroHandler eventTypeAvroHandler)
        {
            var typeWidenerCustomizer = eventTypeAvroHandler.GetTypeWidenerCustomizer(eventType);
            IList<WriteablePropertyDescriptor> writablePropertiesList = new List<WriteablePropertyDescriptor>();
            IList<ExprForge> forgesList = new List<ExprForge>();
            IList<TypeWidenerSPI> widenersList = new List<TypeWidenerSPI>();

            // loop over all columns selected, if any
            for (var i = 0; i < streamNames.Length; i++) {
                WriteablePropertyDescriptor selectedWritable = null;
                TypeWidenerSPI widener = null;

                foreach (var desc in writables) {
                    if (!desc.PropertyName.Equals(streamNames[i])) {
                        continue;
                    }

                    try {
                        widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                            streamNames[i],
                            streamTypes[i].UnderlyingType,
                            desc.PropertyType,
                            desc.PropertyName,
                            false,
                            typeWidenerCustomizer,
                            statementName);
                    }
                    catch (TypeWidenerException ex) {
                        throw new ExprValidationException(ex.Message, ex);
                    }

                    selectedWritable = desc;
                    break;
                }

                if (selectedWritable == null) {
                    var message = "Stream underlying object for stream '" +
                                  streamNames[i] +
                                  "' could not be assigned to any of the properties of the underlying type (missing column names, event property or setter method?)";
                    throw new ExprValidationException(message);
                }

                ExprForge forge = new ExprForgeStreamUnderlying(i, streamTypes[i].UnderlyingType);

                // add
                writablePropertiesList.Add(selectedWritable);
                forgesList.Add(forge);
                widenersList.Add(widener);
            }

            // assign
            var writableProperties = writablePropertiesList.ToArray();
            var exprForges = forgesList.ToArray();
            var wideners = widenersList.ToArray();

            EventBeanManufacturerForge eventManufacturer;
            try {
                eventManufacturer = EventTypeUtility.GetManufacturer(
                    eventType,
                    writableProperties,
                    importService,
                    false,
                    eventTypeAvroHandler);
            }
            catch (EventBeanManufactureException e) {
                throw new ExprValidationException(e.Message, e);
            }

            return new SelectExprInsertNativeWidening(eventType, eventManufacturer, exprForges, wideners);
        }
        public static SelectExprProcessorForge GetInsertUnderlyingNonJoin(
            EventType eventType,
            bool isUsingWildcard,
            StreamTypeService typeService,
            ExprForge[] forges,
            string[] columnNames,
            object[] expressionReturnTypes,
            InsertIntoDesc insertIntoDesc,
            string[] columnNamesAsProvided,
            bool allowNestableTargetFragmentTypes,
            string statementName,
            ImportServiceCompileTime importService,
            EventTypeAvroHandler eventTypeAvroHandler)
        {
            // handle single-column coercion to underlying, i.e. "insert into MapDefinedEvent select doSomethingReturnMap() from MyEvent"
            if (expressionReturnTypes.Length == 1 &&
                expressionReturnTypes[0] is Type &&
                insertIntoDesc.ColumnNames.IsEmpty() &&
                columnNamesAsProvided[0] == null) {

                var resultType = (Type) expressionReturnTypes[0];
                var compatible = (eventType is BaseNestableEventType || eventType is AvroSchemaEventType) &&
                                 TypeHelper.IsSubclassOrImplementsInterface(resultType, eventType.UnderlyingType);
                compatible = compatible | (eventType is JsonEventType && resultType == typeof(string));

                if (compatible) {
                    if (eventType is MapEventType) {
                        return new SelectExprInsertNativeExpressionCoerceMap(eventType, forges[0]);
                    }

                    if (eventType is ObjectArrayEventType) {
                        return new SelectExprInsertNativeExpressionCoerceObjectArray(eventType, forges[0]);
                    }

                    if (eventType is AvroSchemaEventType) {
                        return new SelectExprInsertNativeExpressionCoerceAvro(eventType, forges[0]);
                    }

                    if (eventType is JsonEventType) {
                        return new SelectExprInsertNativeExpressionCoerceJson(eventType, forges[0]);
                    }

                    throw new IllegalStateException("Unrecognized event type " + eventType);
                }
            }

            // handle special case where the target type has no properties and there is a single "null" value selected
            if (eventType.PropertyDescriptors.Count == 0 &&
                columnNames.Length == 1 &&
                columnNames[0].Equals("null") &&
                expressionReturnTypes[0] == null &&
                !isUsingWildcard) {
                EventBeanManufacturerForge eventManufacturer;
                try {
                    eventManufacturer = EventTypeUtility.GetManufacturer(
                        eventType,
                        new WriteablePropertyDescriptor[0],
                        importService,
                        true,
                        eventTypeAvroHandler);
                }
                catch (EventBeanManufactureException e) {
                    throw new ExprValidationException(e.Message, e);
                }

                return new SelectExprInsertNativeNoEval(eventType, eventManufacturer);
            }

            // handle writing to defined columns
            var writableProps = EventTypeUtility.GetWriteableProperties(eventType, false, false);
            var isEligible = CheckEligible(eventType, writableProps, allowNestableTargetFragmentTypes);
            if (!isEligible) {
                return null;
            }

            try {
                return InitializeSetterManufactor(
                    eventType,
                    writableProps,
                    isUsingWildcard,
                    typeService,
                    forges,
                    columnNames,
                    expressionReturnTypes,
                    statementName,
                    importService,
                    eventTypeAvroHandler);
            }
            catch (ExprValidationException ex) {
                if (!(eventType is BeanEventType)) {
                    throw;
                }

                // Try constructor injection
                try {
                    return InitializeCtorInjection(
                        (BeanEventType) eventType,
                        forges,
                        expressionReturnTypes,
                        importService);
                }
                catch (ExprValidationException) {
                    if (writableProps.IsEmpty()) {
                        throw;
                    }

                    throw ex;
                }
            }
        }
        private static SelectExprProcessorForge InitializeSetterManufactor(
            EventType eventType,
            ISet<WriteablePropertyDescriptor> writables,
            bool isUsingWildcard,
            StreamTypeService typeService,
            ExprForge[] expressionForges,
            string[] columnNames,
            object[] expressionReturnTypes,
            string statementName,
            ImportServiceCompileTime importService,
            EventTypeAvroHandler eventTypeAvroHandler)
        {
            var typeWidenerCustomizer = eventTypeAvroHandler.GetTypeWidenerCustomizer(eventType);
            IList<WriteablePropertyDescriptor> writablePropertiesList = new List<WriteablePropertyDescriptor>();
            IList<ExprForge> forgesList = new List<ExprForge>();
            IList<TypeWidenerSPI> widenersList = new List<TypeWidenerSPI>();

            // loop over all columns selected, if any
            for (var i = 0; i < columnNames.Length; i++) {
                WriteablePropertyDescriptor selectedWritable = null;
                TypeWidenerSPI widener = null;
                var forge = expressionForges[i];

                foreach (var desc in writables) {
                    if (!desc.PropertyName.Equals(columnNames[i])) {
                        continue;
                    }

                    var columnType = expressionReturnTypes[i];
                    if (columnType == null) {
                        try {
                            TypeWidenerFactory.GetCheckPropertyAssignType(
                                columnNames[i],
                                null,
                                desc.PropertyType,
                                desc.PropertyName,
                                false,
                                typeWidenerCustomizer,
                                statementName);
                        }
                        catch (TypeWidenerException ex) {
                            throw new ExprValidationException(ex.Message, ex);
                        }
                    }
                    else if (columnType is EventType) {
                        var columnEventType = (EventType) columnType;
                        var returnType = columnEventType.UnderlyingType;
                        try {
                            widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                                columnNames[i],
                                columnEventType.UnderlyingType,
                                desc.PropertyType,
                                desc.PropertyName,
                                false,
                                typeWidenerCustomizer,
                                statementName);
                        }
                        catch (TypeWidenerException ex) {
                            throw new ExprValidationException(ex.Message, ex);
                        }

                        // handle evaluator returning an event
                        if (TypeHelper.IsSubclassOrImplementsInterface(returnType, desc.PropertyType)) {
                            selectedWritable = desc;
                            widener = new ProxyTypeWidenerSPI {
                                ProcWidenResultType = () => desc.PropertyType,
                                ProcWiden = input => {
                                    if (input is EventBean eventBean) {
                                        return eventBean.Underlying;
                                    }

                                    return input;
                                },

                                ProcWidenCodegen = (
                                    expression,
                                    codegenMethodScope,
                                    codegenClassScope) => {
                                    var method = codegenMethodScope
                                        .MakeChild(typeof(object), typeof(TypeWidenerSPI), codegenClassScope)
                                        .AddParam(typeof(object), "input")
                                        .Block
                                        .IfCondition(InstanceOf(Ref("input"), typeof(EventBean)))
                                        .BlockReturn(
                                            ExprDotName(Cast(typeof(EventBean), Ref("input")), "Underlying"))
                                        .MethodReturn(Ref("input"));
                                    return LocalMethodBuild(method).Pass(expression).Call();
                                }
                            };
                            continue;
                        }

                        // find stream
                        var streamNum = 0;
                        for (var j = 0; j < typeService.EventTypes.Length; j++) {
                            if (typeService.EventTypes[j] == columnEventType) {
                                streamNum = j;
                                break;
                            }
                        }

                        forge = new ExprForgeStreamUnderlying(
                            streamNum,
                            typeService.EventTypes[streamNum].UnderlyingType);
                    }
                    else if (columnType is EventType[]) {
                        // handle case where the select-clause contains an fragment array
                        var columnEventType = ((EventType[]) columnType)[0];
                        var componentReturnType = columnEventType.UnderlyingType;
                        var arrayReturnType = componentReturnType.MakeArrayType();

                        var allowObjectArrayToCollectionConversion = eventType is AvroSchemaEventType;
                        try {
                            widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                                columnNames[i],
                                arrayReturnType,
                                desc.PropertyType,
                                desc.PropertyName,
                                allowObjectArrayToCollectionConversion,
                                typeWidenerCustomizer,
                                statementName);
                        }
                        catch (TypeWidenerException ex) {
                            throw new ExprValidationException(ex.Message, ex);
                        }

                        var inner = forge;
                        forge = new ExprForgeStreamWithInner(inner, componentReturnType);
                    }
                    else if (!(columnType is Type columnAsType)) {
                        var message = "Invalid assignment of column '" +
                                      columnNames[i] +
                                      "' of type '" +
                                      columnType +
                                      "' to event property '" +
                                      desc.PropertyName +
                                      "' typed as '" +
                                      desc.PropertyType.CleanName() +
                                      "', column and parameter types mismatch";
                        throw new ExprValidationException(message);
                    }
                    else {
                        try {
                            widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                                columnNames[i],
                                (Type) columnType,
                                desc.PropertyType,
                                desc.PropertyName,
                                false,
                                typeWidenerCustomizer,
                                statementName);
                        }
                        catch (TypeWidenerException ex) {
                            throw new ExprValidationException(ex.Message, ex);
                        }
                    }

                    selectedWritable = desc;
                    break;
                }

                if (selectedWritable == null) {
                    var message = "Column '" +
                                  columnNames[i] +
                                  "' could not be assigned to any of the properties of the underlying type (missing column names, event property, setter method or constructor?)";
                    throw new ExprValidationException(message);
                }

                // add
                writablePropertiesList.Add(selectedWritable);
                forgesList.Add(forge);
                widenersList.Add(widener);
            }

            // handle wildcard
            if (isUsingWildcard) {
                var sourceType = typeService.EventTypes[0];
                foreach (var eventPropDescriptor in sourceType.PropertyDescriptors) {
                    if (eventPropDescriptor.IsRequiresIndex || eventPropDescriptor.IsRequiresMapKey) {
                        continue;
                    }

                    WriteablePropertyDescriptor selectedWritable = null;
                    TypeWidenerSPI widener = null;
                    ExprForge forge = null;

                    foreach (var writableDesc in writables) {
                        if (!writableDesc.PropertyName.Equals(eventPropDescriptor.PropertyName)) {
                            continue;
                        }

                        try {
                            widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                                eventPropDescriptor.PropertyName,
                                eventPropDescriptor.PropertyType,
                                writableDesc.PropertyType,
                                writableDesc.PropertyName,
                                false,
                                typeWidenerCustomizer,
                                statementName);
                        }
                        catch (TypeWidenerException ex) {
                            throw new ExprValidationException(ex.Message, ex);
                        }

                        selectedWritable = writableDesc;

                        var propertyName = eventPropDescriptor.PropertyName;
                        var getter = ((EventTypeSPI) sourceType).GetGetterSPI(propertyName);
                        forge = new ExprForgeStreamWithGetter(getter);
                        break;
                    }

                    if (selectedWritable == null) {
                        var message = "Event property '" +
                                      eventPropDescriptor.PropertyName +
                                      "' could not be assigned to any of the properties of the underlying type (missing column names, event property, setter method or constructor?)";
                        throw new ExprValidationException(message);
                    }

                    writablePropertiesList.Add(selectedWritable);
                    forgesList.Add(forge);
                    widenersList.Add(widener);
                }
            }

            // assign
            var writableProperties = writablePropertiesList.ToArray();
            var exprForges = forgesList.ToArray();
            var wideners = widenersList.ToArray();

            EventBeanManufacturerForge eventManufacturer;
            try {
                eventManufacturer = EventTypeUtility.GetManufacturer(
                    eventType,
                    writableProperties,
                    importService,
                    false,
                    eventTypeAvroHandler);
            }
            catch (EventBeanManufactureException e) {
                throw new ExprValidationException(e.Message, e);
            }
            
            if (eventManufacturer == null) {
                return null;
            }

            return new SelectExprInsertNativeWidening(eventType, eventManufacturer, exprForges, wideners);
        }
Exemple #16
0
 public EventBeanTypedEventFactoryRuntime(EventTypeAvroHandler eventTypeAvroHandler)
 {
     this.eventTypeAvroHandler = eventTypeAvroHandler;
 }
Exemple #17
0
 protected override EventTypeResolvingBeanFactory MakeEventTypeResolvingBeanFactory(
     EventTypeRepository eventTypeRepository,
     EventTypeAvroHandler eventTypeAvroHandler)
 {
     return new EventTypeResolvingBeanFactoryImpl(eventTypeRepository, eventTypeAvroHandler);
 }
Exemple #18
0
 public ModuleCompileTimeServices(
     IContainer container,
     CompilerServices compilerServices,
     Configuration configuration,
     ContextCompileTimeRegistry contextCompileTimeRegistry,
     ContextCompileTimeResolver contextCompileTimeResolver,
     BeanEventTypeStemService beanEventTypeStemService,
     BeanEventTypeFactoryPrivate beanEventTypeFactoryPrivate,
     DatabaseConfigServiceCompileTime databaseConfigServiceCompileTime,
     ImportServiceCompileTime importService,
     ExprDeclaredCompileTimeRegistry exprDeclaredCompileTimeRegistry,
     ExprDeclaredCompileTimeResolver exprDeclaredCompileTimeResolver,
     EventTypeAvroHandler eventTypeAvroHandler,
     EventTypeCompileTimeRegistry eventTypeCompileTimeRegistry,
     EventTypeCompileTimeResolver eventTypeCompileTimeResolver,
     EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
     IndexCompileTimeRegistry indexCompileTimeRegistry,
     ModuleDependenciesCompileTime moduleDependencies,
     ModuleAccessModifierService moduleVisibilityRules,
     NamedWindowCompileTimeResolver namedWindowCompileTimeResolver,
     NamedWindowCompileTimeRegistry namedWindowCompileTimeRegistry,
     PatternObjectResolutionService patternObjectResolutionService,
     ScriptCompileTimeRegistry scriptCompileTimeRegistry,
     ScriptCompileTimeResolver scriptCompileTimeResolver,
     ScriptServiceCompileTime scriptServiceCompileTime,
     TableCompileTimeRegistry tableCompileTimeRegistry,
     TableCompileTimeResolver tableCompileTimeResolver,
     VariableCompileTimeRegistry variableCompileTimeRegistry,
     VariableCompileTimeResolver variableCompileTimeResolver,
     ViewResolutionService viewResolutionService,
     XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory)
 {
     Container = container;
     CompilerServices = compilerServices;
     Configuration = configuration;
     ContextCompileTimeRegistry = contextCompileTimeRegistry;
     ContextCompileTimeResolver = contextCompileTimeResolver;
     BeanEventTypeStemService = beanEventTypeStemService;
     BeanEventTypeFactoryPrivate = beanEventTypeFactoryPrivate;
     DatabaseConfigServiceCompileTime = databaseConfigServiceCompileTime;
     ImportServiceCompileTime = importService;
     ExprDeclaredCompileTimeRegistry = exprDeclaredCompileTimeRegistry;
     ExprDeclaredCompileTimeResolver = exprDeclaredCompileTimeResolver;
     EventTypeAvroHandler = eventTypeAvroHandler;
     EventTypeCompileTimeRegistry = eventTypeCompileTimeRegistry;
     EventTypeCompileTimeResolver = eventTypeCompileTimeResolver;
     EventTypeRepositoryPreconfigured = eventTypeRepositoryPreconfigured;
     IndexCompileTimeRegistry = indexCompileTimeRegistry;
     ModuleDependencies = moduleDependencies;
     ModuleVisibilityRules = moduleVisibilityRules;
     NamedWindowCompileTimeResolver = namedWindowCompileTimeResolver;
     NamedWindowCompileTimeRegistry = namedWindowCompileTimeRegistry;
     PatternObjectResolutionService = patternObjectResolutionService;
     ScriptServiceCompileTime = scriptServiceCompileTime;
     ScriptCompileTimeRegistry = scriptCompileTimeRegistry;
     ScriptCompileTimeResolver = scriptCompileTimeResolver;
     TableCompileTimeRegistry = tableCompileTimeRegistry;
     TableCompileTimeResolver = tableCompileTimeResolver;
     VariableCompileTimeRegistry = variableCompileTimeRegistry;
     VariableCompileTimeResolver = variableCompileTimeResolver;
     ViewResolutionService = viewResolutionService;
     XmlFragmentEventTypeFactory = xmlFragmentEventTypeFactory;
 }
Exemple #19
0
        public static EventPropertyGetterSPI GetGetter(
            Schema avroSchema,
            string moduleName,
            Dictionary<string, EventPropertyGetterSPI> propertyGetterCache,
            IDictionary<string, PropertySetDescriptorItem> propertyDescriptors,
            string propertyName,
            bool addToCache,
            EventBeanTypedEventFactory eventAdapterService,
            EventTypeAvroHandler eventTypeAvroHandler,
            AvroEventTypeFragmentTypeCache fragmentTypeCache)
        {
            var getter = propertyGetterCache.Get(propertyName);
            if (getter != null) {
                return getter;
            }

            var unescapePropName = StringValue.UnescapeDot(propertyName);
            var item = propertyDescriptors.Get(unescapePropName);
            if (item != null) {
                getter = item.PropertyGetter;
                MayAddToGetterCache(propertyName, propertyGetterCache, getter, true);
                return getter;
            }

            // see if this is a nested property
            var index = StringValue.UnescapedIndexOfDot(propertyName);
            if (index == -1) {
                var prop = PropertyParser.ParseAndWalkLaxToSimple(propertyName);
                if (prop is IndexedProperty indexedProp) {
                    var field = avroSchema.GetField(indexedProp.PropertyNameAtomic);
                    if (field == null) {
                        return null;
                    }

                    if ((field.Schema.Tag != Schema.Type.Array) &&
                        (field.Schema.Tag != Schema.Type.String)) {
                        return null;
                    }

                    var fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(
                        field.Schema,
                        moduleName,
                        eventAdapterService,
                        eventTypeAvroHandler,
                        fragmentTypeCache);
                    getter = new AvroEventBeanGetterIndexed(
                        field,
                        indexedProp.Index,
                        fragmentEventType?.FragmentType,
                        eventAdapterService);
                    MayAddToGetterCache(propertyName, propertyGetterCache, getter, addToCache);
                    return getter;
                }

                if (prop is MappedProperty mappedProp) {
                    Field field = avroSchema.GetField(mappedProp.PropertyNameAtomic);
                    if (field == null || field.Schema.Tag != Schema.Type.Map) {
                        return null;
                    }

                    getter = new AvroEventBeanGetterMapped(field, mappedProp.Key);
                    MayAddToGetterCache(propertyName, propertyGetterCache, getter, addToCache);
                    return getter;
                }

                if (prop is DynamicIndexedProperty dynamicIndexedProp) {
                    getter = new AvroEventBeanGetterIndexedDynamic(
                        dynamicIndexedProp.PropertyNameAtomic,
                        dynamicIndexedProp.Index);
                    MayAddToGetterCache(propertyName, propertyGetterCache, getter, addToCache);
                    return getter;
                }

                if (prop is DynamicMappedProperty dynamicMappedProp) {
                    getter = new AvroEventBeanGetterMappedDynamic(
                        dynamicMappedProp.PropertyNameAtomic,
                        dynamicMappedProp.Key);
                    MayAddToGetterCache(propertyName, propertyGetterCache, getter, addToCache);
                    return getter;
                }

                if (prop is DynamicSimpleProperty) {
                    getter = new AvroEventBeanGetterSimpleDynamic(prop.PropertyNameAtomic);
                    MayAddToGetterCache(propertyName, propertyGetterCache, getter, addToCache);
                    return getter;
                }

                return null; // simple property already cached
            }

            // Take apart the nested property into a map key and a nested value class property name
            var propertyTop = StringValue.UnescapeDot(propertyName.Substring(0, index));
            var propertyNested = propertyName.Substring(index + 1);
            var isRootedDynamic = false;

            // If the property is dynamic, remove the ? since the property type is defined without
            if (propertyTop.EndsWith("?")) {
                propertyTop = propertyTop.Substring(0, propertyTop.Length - 1);
                isRootedDynamic = true;
            }

            var propTop = PropertyParser.ParseAndWalkLaxToSimple(propertyTop);
            Field fieldTop = avroSchema.GetField(propTop.PropertyNameAtomic);

            // field is known and is a record
            if (fieldTop != null && fieldTop.Schema.Tag == Schema.Type.Record && propTop is SimpleProperty) {
                var factory = new GetterNestedFactoryRootedSimple(eventAdapterService, fieldTop);
                var property = PropertyParser.ParseAndWalk(propertyNested, isRootedDynamic);
                getter = PropertyGetterNested(
                    factory,
                    fieldTop.Schema,
                    property,
                    moduleName,
                    eventAdapterService,
                    eventTypeAvroHandler,
                    fragmentTypeCache);
                MayAddToGetterCache(propertyName, propertyGetterCache, getter, addToCache);
                return getter;
            }

            // field is known and is a record
            if (fieldTop != null && propTop is IndexedProperty indexedProperty) {
                if ((fieldTop.Schema.Tag == Schema.Type.Array) ||
                    (fieldTop.Schema.Tag == Schema.Type.String)) {
                    var factory = new GetterNestedFactoryRootedIndexed(
                        eventAdapterService,
                        fieldTop,
                        indexedProperty.Index);
                    var property = PropertyParser.ParseAndWalk(propertyNested, isRootedDynamic);
                    getter = PropertyGetterNested(
                        factory,
                        fieldTop.Schema.AsArraySchema().ItemSchema,
                        property,
                        moduleName,
                        eventAdapterService,
                        eventTypeAvroHandler,
                        fragmentTypeCache);
                    MayAddToGetterCache(propertyName, propertyGetterCache, getter, addToCache);
                    return getter;
                }
            }

            // field is not known or is not a record
            if (!isRootedDynamic) {
                return null;
            }

            var propertyX = PropertyParser.ParseAndWalk(propertyNested, true);
            var innerGetter = GetDynamicGetter(propertyX);
            getter = new AvroEventBeanGetterNestedDynamicPoly(propertyTop, innerGetter);
            MayAddToGetterCache(propertyName, propertyGetterCache, getter, addToCache);
            return getter;
        }
Exemple #20
0
 protected override EventBeanTypedEventFactory MakeEventBeanTypedEventFactory(EventTypeAvroHandler eventTypeAvroHandler)
 {
     return new EventBeanTypedEventFactoryRuntime(eventTypeAvroHandler);
 }
 protected abstract EventBeanTypedEventFactory MakeEventBeanTypedEventFactory(EventTypeAvroHandler eventTypeAvroHandler);
 protected abstract EventTypeResolvingBeanFactory MakeEventTypeResolvingBeanFactory(
     EventTypeRepository eventTypeRepository,
     EventTypeAvroHandler eventTypeAvroHandler);
Exemple #23
0
        private static EventPropertyGetterSPI PropertyGetterNested(
            GetterNestedFactory factory,
            Schema fieldSchema,
            Property property,
            string moduleName,
            EventBeanTypedEventFactory eventAdapterService,
            EventTypeAvroHandler eventTypeAvroHandler,
            AvroEventTypeFragmentTypeCache fragmentTypeCache)
        {
            if (property is SimpleProperty) {
                Field fieldNested = fieldSchema.GetField(property.PropertyNameAtomic);
                if (fieldNested == null) {
                    return null;
                }

                var fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(
                    fieldNested.Schema,
                    moduleName,
                    eventAdapterService,
                    eventTypeAvroHandler,
                    fragmentTypeCache);
                return factory.MakeSimple(
                    fieldNested,
                    fragmentEventType?.FragmentType,
                    AvroTypeUtil.PropertyType(fieldNested.Schema));
            }

            if (property is IndexedProperty indexedProperty) {
                var fieldNested = fieldSchema.GetField(indexedProperty.PropertyNameAtomic);
                if (fieldNested == null) {
                    return null;
                }

                if ((fieldNested.Schema.Tag != Schema.Type.Array) &&
                    (fieldNested.Schema.Tag != Schema.Type.String)) {
                    return null;
                }

                var fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(
                    fieldNested.Schema,
                    moduleName,
                    eventAdapterService,
                    eventTypeAvroHandler,
                    fragmentTypeCache);
                
                return factory.MakeIndexed(fieldNested, indexedProperty.Index, fragmentEventType?.FragmentType);
            }

            if (property is MappedProperty mappedProperty) {
                Field fieldNested = fieldSchema.GetField(mappedProperty.PropertyNameAtomic);
                if (fieldNested == null || fieldNested.Schema.Tag != Schema.Type.Map) {
                    return null;
                }

                return factory.MakeMapped(fieldNested, mappedProperty.Key);
            }

            if (property is DynamicProperty) {
                if (property is DynamicSimpleProperty) {
                    return factory.MakeDynamicSimple(property.PropertyNameAtomic);
                }

                throw new NotSupportedException();
            }

            var nested = (NestedProperty) property;
            var allSimple = true;
            foreach (var levelProperty in nested.Properties) {
                if (!(levelProperty is SimpleProperty)) {
                    allSimple = false;
                    break;
                }
            }

            if (allSimple) {
                var currentSchema = fieldSchema;
                var count = 0;
                var path = new Field[nested.Properties.Count];
                var types = new Type[nested.Properties.Count];
                foreach (var levelProperty in nested.Properties) {
                    if (currentSchema.Tag != Schema.Type.Record) {
                        return null;
                    }

                    Field fieldNested = currentSchema.GetField(levelProperty.PropertyNameAtomic);
                    if (fieldNested == null) {
                        return null;
                    }

                    currentSchema = fieldNested.Schema;
                    path[count] = fieldNested;
                    types[count] = AvroTypeUtil.PropertyType(currentSchema);
                    count++;
                }

                var fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(
                    currentSchema,
                    moduleName,
                    eventAdapterService,
                    eventTypeAvroHandler,
                    fragmentTypeCache);
                return factory.MakeNestedSimpleMultiLevel(path, types, fragmentEventType?.FragmentType);
            }

            var getters = new AvroEventPropertyGetter[nested.Properties.Count];
            var countX = 0;
            var currentSchemaX = fieldSchema;
            foreach (var levelProperty in nested.Properties) {
                if (currentSchemaX == null) {
                    return null;
                }

                if (levelProperty is SimpleProperty) {
                    Field fieldNested = currentSchemaX.GetField(levelProperty.PropertyNameAtomic);
                    if (fieldNested == null) {
                        return null;
                    }

                    var fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(
                        fieldNested.Schema,
                        moduleName,
                        eventAdapterService,
                        eventTypeAvroHandler,
                        fragmentTypeCache);
                    var propertyType = AvroTypeUtil.PropertyType(fieldNested.Schema);
                    getters[countX] = new AvroEventBeanGetterSimple(
                        fieldNested,
                        fragmentEventType?.FragmentType,
                        eventAdapterService,
                        propertyType);
                    currentSchemaX = fieldNested.Schema;
                }
                else if (levelProperty is IndexedProperty indexed) {
                    var fieldIndexed = currentSchemaX.GetField(indexed.PropertyNameAtomic);
                    if (fieldIndexed == null) {
                        return null;
                    }

                    if ((fieldIndexed.Schema.Tag != Schema.Type.Array) &&
                        (fieldIndexed.Schema.Tag != Schema.Type.String)) {
                        return null;
                    }

                    var fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(
                        fieldIndexed.Schema,
                        moduleName,
                        eventAdapterService,
                        eventTypeAvroHandler,
                        fragmentTypeCache);
                    getters[countX] = new AvroEventBeanGetterIndexed(
                        fieldIndexed,
                        indexed.Index,
                        fragmentEventType?.FragmentType,
                        eventAdapterService);
                    currentSchemaX = fieldIndexed.Schema.AsArraySchema().ItemSchema;
                }
                else if (levelProperty is MappedProperty mapped) {
                    Field fieldMapped = currentSchemaX.GetField(mapped.PropertyNameAtomic);
                    if (fieldMapped == null || fieldMapped.Schema.Tag != Schema.Type.Map) {
                        return null;
                    }

                    getters[countX] = new AvroEventBeanGetterMapped(fieldMapped, mapped.Key);
                    currentSchemaX = fieldMapped.Schema;
                }
                else if (levelProperty is DynamicSimpleProperty) {
                    if (currentSchemaX.Tag != Schema.Type.Record) {
                        return null;
                    }

                    Field fieldDynamic = currentSchemaX.GetField(levelProperty.PropertyNameAtomic);
                    getters[countX] = new AvroEventBeanGetterSimpleDynamic(levelProperty.PropertyNameAtomic);
                    if (fieldDynamic.Schema.Tag == Schema.Type.Record) {
                        currentSchemaX = fieldDynamic.Schema;
                    }
                    else if (fieldDynamic.Schema.Tag == Schema.Type.Union) {
                        currentSchemaX = AvroSchemaUtil.FindUnionRecordSchemaSingle(fieldDynamic.Schema);
                    }
                }
                else {
                    throw new NotSupportedException();
                }

                countX++;
            }

            return factory.MakeNestedPolyMultiLevel(getters);
        }
Exemple #24
0
 public EPServicesContext(
     IContainer container,
     AggregationServiceFactoryService aggregationServiceFactoryService,
     BeanEventTypeFactoryPrivate beanEventTypeFactoryPrivate,
     BeanEventTypeStemService beanEventTypeStemService,
     ClassForNameProvider classForNameProvider,
     ParentClassLoader classLoaderParent,
     PathRegistry <string, ClassProvided> classProvidedPathRegistry,
     Configuration configSnapshot,
     ContextManagementService contextManagementService,
     PathRegistry <string, ContextMetaData> contextPathRegistry,
     ContextServiceFactory contextServiceFactory,
     EPDataFlowServiceImpl dataflowService,
     DataFlowFilterServiceAdapter dataFlowFilterServiceAdapter,
     DatabaseConfigServiceRuntime databaseConfigServiceRuntime,
     DeploymentLifecycleService deploymentLifecycleService,
     DispatchService dispatchService,
     RuntimeEnvContext runtimeEnvContext,
     RuntimeSettingsService runtimeSettingsService,
     string runtimeURI,
     ImportServiceRuntime importServiceRuntime,
     EPStatementFactory epStatementFactory,
     PathRegistry <string, ExpressionDeclItem> exprDeclaredPathRegistry,
     IReaderWriterLock eventProcessingRWLock,
     EPServicesHA epServicesHA,
     EPRuntimeSPI epRuntime,
     EventBeanService eventBeanService,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     EPRenderEventServiceImpl eventRenderer,
     EventSerdeFactory eventSerdeFactory,
     EventTableIndexService eventTableIndexService,
     EventTypeAvroHandler eventTypeAvroHandler,
     EventTypeFactory eventTypeFactory,
     EventTypeIdResolver eventTypeIdResolver,
     PathRegistry <string, EventType> eventTypePathRegistry,
     EventTypeRepositoryImpl eventTypeRepositoryBus,
     EventTypeResolvingBeanFactory eventTypeResolvingBeanFactory,
     EventTypeSerdeRepository eventTypeSerdeRepository,
     ExceptionHandlingService exceptionHandlingService,
     ExpressionResultCacheService expressionResultCacheService,
     FilterBooleanExpressionFactory filterBooleanExpressionFactory,
     FilterServiceSPI filterService,
     FilterSharedBoolExprRepository filterSharedBoolExprRepository,
     FilterSharedLookupableRepository filterSharedLookupableRepository,
     HistoricalDataCacheFactory historicalDataCacheFactory,
     InternalEventRouterImpl internalEventRouter,
     MetricReportingService metricReportingService,
     MultiMatchHandlerFactory multiMatchHandlerFactory,
     NamedWindowConsumerManagementService namedWindowConsumerManagementService,
     NamedWindowDispatchService namedWindowDispatchService,
     NamedWindowFactoryService namedWindowFactoryService,
     NamedWindowManagementService namedWindowManagementService,
     PathRegistry <string, NamedWindowMetaData> namedWindowPathRegistry,
     PatternFactoryService patternFactoryService,
     PatternSubexpressionPoolRuntimeSvc patternSubexpressionPoolEngineSvc,
     ResultSetProcessorHelperFactory resultSetProcessorHelperFactory,
     RowRecogStateRepoFactory rowRecogStateRepoFactory,
     RowRecogStatePoolRuntimeSvc rowRecogStatePoolEngineSvc,
     SchedulingServiceSPI schedulingService,
     PathRegistry <NameAndParamNum, ExpressionScriptProvided> scriptPathRegistry,
     ScriptCompiler scriptCompiler,
     StageRecoveryService stageRecoveryService,
     StatementLifecycleService statementLifecycleService,
     StatementAgentInstanceLockFactory statementAgentInstanceLockFactory,
     StatementResourceHolderBuilder statementResourceHolderBuilder,
     TableExprEvaluatorContext tableExprEvaluatorContext,
     TableManagementService tableManagementService,
     PathRegistry <string, TableMetaData> tablePathRegistry,
     ThreadingService threadingService,
     TimeAbacus timeAbacus,
     TimeSourceService timeSourceService,
     TimerService timerService,
     VariableManagementService variableManagementService,
     PathRegistry <string, VariableMetaData> variablePathRegistry,
     ViewableActivatorFactory viewableActivatorFactory,
     ViewFactoryService viewFactoryService,
     ViewServicePreviousFactory viewServicePreviousFactory,
     XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory)
 {
     _container = container;
     _aggregationServiceFactoryService = aggregationServiceFactoryService;
     _beanEventTypeFactoryPrivate      = beanEventTypeFactoryPrivate;
     _beanEventTypeStemService         = beanEventTypeStemService;
     _classForNameProvider             = classForNameProvider;
     _classLoaderParent            = classLoaderParent;
     _classProvidedPathRegistry    = classProvidedPathRegistry;
     _configSnapshot               = configSnapshot;
     _contextManagementService     = contextManagementService;
     _contextPathRegistry          = contextPathRegistry;
     _contextServiceFactory        = contextServiceFactory;
     _dataflowService              = dataflowService;
     _dataFlowFilterServiceAdapter = dataFlowFilterServiceAdapter;
     _databaseConfigServiceRuntime = databaseConfigServiceRuntime;
     _deploymentLifecycleService   = deploymentLifecycleService;
     _dispatchService              = dispatchService;
     _runtimeEnvContext            = runtimeEnvContext;
     _runtimeSettingsService       = runtimeSettingsService;
     _runtimeUri               = runtimeURI;
     _importServiceRuntime     = importServiceRuntime;
     _epStatementFactory       = epStatementFactory;
     _exprDeclaredPathRegistry = exprDeclaredPathRegistry;
     _eventProcessingRWLock    = eventProcessingRWLock;
     _epServicesHA             = epServicesHA;
     _epRuntime                            = epRuntime;
     _eventBeanService                     = eventBeanService;
     _eventBeanTypedEventFactory           = eventBeanTypedEventFactory;
     _eventRenderer                        = eventRenderer;
     _eventSerdeFactory                    = eventSerdeFactory;
     _eventTableIndexService               = eventTableIndexService;
     _eventTypeAvroHandler                 = eventTypeAvroHandler;
     _eventTypeFactory                     = eventTypeFactory;
     _eventTypeIdResolver                  = eventTypeIdResolver;
     _eventTypePathRegistry                = eventTypePathRegistry;
     _eventTypeRepositoryBus               = eventTypeRepositoryBus;
     _eventTypeResolvingBeanFactory        = eventTypeResolvingBeanFactory;
     _eventTypeSerdeRepository             = eventTypeSerdeRepository;
     _exceptionHandlingService             = exceptionHandlingService;
     _expressionResultCacheService         = expressionResultCacheService;
     _filterBooleanExpressionFactory       = filterBooleanExpressionFactory;
     _filterService                        = filterService;
     _filterSharedBoolExprRepository       = filterSharedBoolExprRepository;
     _filterSharedLookupableRepository     = filterSharedLookupableRepository;
     _historicalDataCacheFactory           = historicalDataCacheFactory;
     _internalEventRouter                  = internalEventRouter;
     _metricReportingService               = metricReportingService;
     _multiMatchHandlerFactory             = multiMatchHandlerFactory;
     _namedWindowConsumerManagementService = namedWindowConsumerManagementService;
     _namedWindowDispatchService           = namedWindowDispatchService;
     _namedWindowFactoryService            = namedWindowFactoryService;
     _namedWindowManagementService         = namedWindowManagementService;
     _namedWindowPathRegistry              = namedWindowPathRegistry;
     _patternFactoryService                = patternFactoryService;
     _patternSubexpressionPoolEngineSvc    = patternSubexpressionPoolEngineSvc;
     _resultSetProcessorHelperFactory      = resultSetProcessorHelperFactory;
     _rowRecogStateRepoFactory             = rowRecogStateRepoFactory;
     _rowRecogStatePoolEngineSvc           = rowRecogStatePoolEngineSvc;
     _schedulingService                    = schedulingService;
     _scriptPathRegistry                   = scriptPathRegistry;
     _stageRecoveryService                 = stageRecoveryService;
     _statementLifecycleService            = statementLifecycleService;
     _statementAgentInstanceLockFactory    = statementAgentInstanceLockFactory;
     _statementResourceHolderBuilder       = statementResourceHolderBuilder;
     _tableExprEvaluatorContext            = tableExprEvaluatorContext;
     _tableManagementService               = tableManagementService;
     _tablePathRegistry                    = tablePathRegistry;
     _threadingService                     = threadingService;
     _timeAbacus                           = timeAbacus;
     _timeSourceService                    = timeSourceService;
     _timerService                         = timerService;
     _variableManagementService            = variableManagementService;
     _variablePathRegistry                 = variablePathRegistry;
     _viewableActivatorFactory             = viewableActivatorFactory;
     _viewFactoryService                   = viewFactoryService;
     _viewServicePreviousFactory           = viewServicePreviousFactory;
     _xmlFragmentEventTypeFactory          = xmlFragmentEventTypeFactory;
     _scriptCompiler                       = scriptCompiler;
 }
Exemple #25
0
        public ModuleCompileTimeServices(
            IContainer container,
            CompilerServices compilerServices,
            Configuration configuration,
            ContextCompileTimeRegistry contextCompileTimeRegistry,
            ContextCompileTimeResolver contextCompileTimeResolver,
            BeanEventTypeStemService beanEventTypeStemService,
            BeanEventTypeFactoryPrivate beanEventTypeFactoryPrivate,
            ClassProvidedCompileTimeRegistry classProvidedCompileTimeRegistry,
            ClassProvidedCompileTimeResolver classProvidedCompileTimeResolver,
            DatabaseConfigServiceCompileTime databaseConfigServiceCompileTime,
            ImportServiceCompileTime importService,
            ExprDeclaredCompileTimeRegistry exprDeclaredCompileTimeRegistry,
            ExprDeclaredCompileTimeResolver exprDeclaredCompileTimeResolver,
            EventTypeAvroHandler eventTypeAvroHandler,
            EventTypeCompileTimeRegistry eventTypeCompileTimeRegistry,
            EventTypeCompileTimeResolver eventTypeCompileTimeResolver,
            EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
            bool fireAndForget,
            IndexCompileTimeRegistry indexCompileTimeRegistry,
            ModuleDependenciesCompileTime moduleDependencies,
            ModuleAccessModifierService moduleVisibilityRules,
            NamedWindowCompileTimeResolver namedWindowCompileTimeResolver,
            NamedWindowCompileTimeRegistry namedWindowCompileTimeRegistry,
            ParentClassLoader parentClassLoader,
            PatternObjectResolutionService patternObjectResolutionService,
            ScriptCompileTimeRegistry scriptCompileTimeRegistry,
            ScriptCompileTimeResolver scriptCompileTimeResolver,
            ScriptCompiler scriptCompiler,
            SerdeEventTypeCompileTimeRegistry serdeEventTypeRegistry,
            SerdeCompileTimeResolver serdeResolver, 
            TableCompileTimeRegistry tableCompileTimeRegistry,
            TableCompileTimeResolver tableCompileTimeResolver,
            VariableCompileTimeRegistry variableCompileTimeRegistry,
            VariableCompileTimeResolver variableCompileTimeResolver,
            ViewResolutionService viewResolutionService,
            XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory)
        {
            var generation = Interlocked.Increment(ref _generation);
            
            Namespace = $"generation_{generation}";

            Container = container;
            CompilerServices = compilerServices;
            Configuration = configuration;
            ContextCompileTimeRegistry = contextCompileTimeRegistry;
            ContextCompileTimeResolver = contextCompileTimeResolver;
            BeanEventTypeStemService = beanEventTypeStemService;
            BeanEventTypeFactoryPrivate = beanEventTypeFactoryPrivate;
            DatabaseConfigServiceCompileTime = databaseConfigServiceCompileTime;
            ImportServiceCompileTime = importService;
            ExprDeclaredCompileTimeRegistry = exprDeclaredCompileTimeRegistry;
            ExprDeclaredCompileTimeResolver = exprDeclaredCompileTimeResolver;
            EventTypeAvroHandler = eventTypeAvroHandler;
            EventTypeCompileTimeRegistry = eventTypeCompileTimeRegistry;
            EventTypeCompileTimeResolver = eventTypeCompileTimeResolver;
            EventTypeRepositoryPreconfigured = eventTypeRepositoryPreconfigured;
            IndexCompileTimeRegistry = indexCompileTimeRegistry;
            ModuleDependencies = moduleDependencies;
            ModuleVisibilityRules = moduleVisibilityRules;
            NamedWindowCompileTimeResolver = namedWindowCompileTimeResolver;
            NamedWindowCompileTimeRegistry = namedWindowCompileTimeRegistry;
            ParentClassLoader = parentClassLoader;
            PatternObjectResolutionService = patternObjectResolutionService;
            ScriptCompileTimeRegistry = scriptCompileTimeRegistry;
            ScriptCompileTimeResolver = scriptCompileTimeResolver;
            ScriptCompiler = scriptCompiler;
            TableCompileTimeRegistry = tableCompileTimeRegistry;
            TableCompileTimeResolver = tableCompileTimeResolver;
            VariableCompileTimeRegistry = variableCompileTimeRegistry;
            VariableCompileTimeResolver = variableCompileTimeResolver;
            ViewResolutionService = viewResolutionService;
            XmlFragmentEventTypeFactory = xmlFragmentEventTypeFactory;

            #region ESPER_8.5.1
            ClassProvidedCompileTimeRegistry = classProvidedCompileTimeRegistry;
            ClassProvidedCompileTimeResolver = classProvidedCompileTimeResolver;
            SerdeEventTypeRegistry = serdeEventTypeRegistry;
            SerdeResolver = serdeResolver;
            IsFireAndForget = fireAndForget;
            #endregion
        }
        private static ModuleCompileTimeServices GetServices(
            CompilerArguments arguments,
            string moduleName,
            ICollection<string> moduleUses,
            bool isFireAndForget)
        {
            var configuration = arguments.Configuration;
            var path = arguments.Path;
            var options = arguments.Options;
            
            // script
            var scriptCompiler = MakeScriptCompiler(configuration);

            // imports
            var importServiceCompileTime = MakeImportService(configuration);
            var classLoaderParent = new ParentClassLoader(importServiceCompileTime.ClassLoader);
            var container = importServiceCompileTime.Container;

            // resolve pre-configured bean event types, make bean-stem service
            var resolvedBeanEventTypes = BeanEventTypeRepoUtil.ResolveBeanEventTypes(
                configuration.Common.EventTypeNames,
                importServiceCompileTime);
            var beanEventTypeStemService = BeanEventTypeRepoUtil.MakeBeanEventTypeStemService(
                configuration,
                resolvedBeanEventTypes,
                EventBeanTypedEventFactoryCompileTime.INSTANCE);

            // allocate repositories
            var eventTypeRepositoryPreconfigured = new EventTypeRepositoryImpl(true);
            var eventTypeCompileRegistry = new EventTypeCompileTimeRegistry(eventTypeRepositoryPreconfigured);
            var beanEventTypeFactoryPrivate = new BeanEventTypeFactoryPrivate(
                EventBeanTypedEventFactoryCompileTime.INSTANCE, EventTypeFactoryImpl.GetInstance(container), beanEventTypeStemService);
            var variableRepositoryPreconfigured = new VariableRepositoryPreconfigured();

            // allocate path registries
            var pathEventTypes = new PathRegistry<string, EventType>(PathRegistryObjectType.EVENTTYPE);
            var pathNamedWindows = new PathRegistry<string, NamedWindowMetaData>(PathRegistryObjectType.NAMEDWINDOW);
            var pathTables = new PathRegistry<string, TableMetaData>(PathRegistryObjectType.TABLE);
            var pathContexts = new PathRegistry<string, ContextMetaData>(PathRegistryObjectType.CONTEXT);
            var pathVariables = new PathRegistry<string, VariableMetaData>(PathRegistryObjectType.VARIABLE);
            var pathExprDeclared = new PathRegistry<string, ExpressionDeclItem>(PathRegistryObjectType.EXPRDECL);
            var pathScript = new PathRegistry<NameAndParamNum, ExpressionScriptProvided>(PathRegistryObjectType.SCRIPT);
            var pathClassProvided = new PathRegistry<string, ClassProvided>(PathRegistryObjectType.CLASSPROVIDED);

            // add runtime-path which is the information an existing runtime may have
            if (path.CompilerPathables != null) {
                foreach (EPCompilerPathable pathable in path.CompilerPathables) {
                    EPCompilerPathableImpl impl = (EPCompilerPathableImpl) pathable;
                    pathVariables.MergeFrom(impl.VariablePathRegistry);
                    pathEventTypes.MergeFrom(impl.EventTypePathRegistry);
                    pathExprDeclared.MergeFrom(impl.ExprDeclaredPathRegistry);
                    pathNamedWindows.MergeFrom(impl.NamedWindowPathRegistry);
                    pathTables.MergeFrom(impl.TablePathRegistry);
                    pathContexts.MergeFrom(impl.ContextPathRegistry);
                    pathScript.MergeFrom(impl.ScriptPathRegistry);
                    pathClassProvided.MergeFrom(impl.ClassProvidedPathRegistry);
                    eventTypeRepositoryPreconfigured.MergeFrom(impl.EventTypePreconfigured);
                    variableRepositoryPreconfigured.MergeFrom(impl.VariablePreconfigured);

                    JsonEventTypeUtility.AddJsonUnderlyingClass(pathEventTypes, classLoaderParent);
                }
            }
            
            // build preconfigured type system
            EventTypeRepositoryBeanTypeUtil.BuildBeanTypes(
                beanEventTypeStemService,
                eventTypeRepositoryPreconfigured,
                resolvedBeanEventTypes,
                beanEventTypeFactoryPrivate,
                configuration.Common.EventTypesBean);
            EventTypeRepositoryMapTypeUtil.BuildMapTypes(
                eventTypeRepositoryPreconfigured,
                configuration.Common.MapTypeConfigurations,
                configuration.Common.EventTypesMapEvents,
                configuration.Common.EventTypesNestableMapEvents,
                beanEventTypeFactoryPrivate,
                importServiceCompileTime);
            EventTypeRepositoryOATypeUtil.BuildOATypes(
                eventTypeRepositoryPreconfigured,
                configuration.Common.ObjectArrayTypeConfigurations,
                configuration.Common.EventTypesNestableObjectArrayEvents,
                beanEventTypeFactoryPrivate,
                importServiceCompileTime);
            XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory = new XMLFragmentEventTypeFactory(
                beanEventTypeFactoryPrivate,
                eventTypeCompileRegistry,
                eventTypeRepositoryPreconfigured);
            EventTypeRepositoryXMLTypeUtil.BuildXMLTypes(
                eventTypeRepositoryPreconfigured,
                configuration.Common.EventTypesXMLDOM,
                beanEventTypeFactoryPrivate,
                xmlFragmentEventTypeFactory,
                container.ResourceManager());
            EventTypeAvroHandler eventTypeAvroHandler = EventTypeAvroHandlerFactory.Resolve(
                importServiceCompileTime,
                configuration.Common.EventMeta.AvroSettings,
                EventTypeAvroHandlerConstants.COMPILE_TIME_HANDLER_IMPL);
            EventTypeRepositoryAvroTypeUtil.BuildAvroTypes(
                eventTypeRepositoryPreconfigured,
                configuration.Common.EventTypesAvro,
                eventTypeAvroHandler,
                beanEventTypeFactoryPrivate.EventBeanTypedEventFactory);
            EventTypeRepositoryVariantStreamUtil.BuildVariantStreams(
                eventTypeRepositoryPreconfigured,
                configuration.Common.VariantStreams,
                EventTypeFactoryImpl.GetInstance(container));

            // build preconfigured variables
            VariableUtil.ConfigureVariables(
                variableRepositoryPreconfigured,
                configuration.Common.Variables,
                importServiceCompileTime,
                EventBeanTypedEventFactoryCompileTime.INSTANCE,
                eventTypeRepositoryPreconfigured,
                beanEventTypeFactoryPrivate);

            var deploymentNumber = -1;

            foreach (var unit in path.Compileds) {
                deploymentNumber++;
                var provider = ModuleProviderUtil.Analyze(unit, classLoaderParent, pathClassProvided);
                var unitModuleName = provider.ModuleProvider.ModuleName;

                // initialize event types
                var moduleTypes = new Dictionary<string, EventType>();
                var eventTypeResolver = new EventTypeResolverImpl(
                    moduleTypes,
                    pathEventTypes,
                    eventTypeRepositoryPreconfigured,
                    beanEventTypeFactoryPrivate,
                    EventSerdeFactoryDefault.INSTANCE);
                var eventTypeCollector = new EventTypeCollectorImpl(
                    container,
                    moduleTypes,
                    beanEventTypeFactoryPrivate,
                    provider.ClassLoader,
                    EventTypeFactoryImpl.GetInstance(container),
                    beanEventTypeStemService,
                    eventTypeResolver,
                    xmlFragmentEventTypeFactory,
                    eventTypeAvroHandler,
                    EventBeanTypedEventFactoryCompileTime.INSTANCE,
                    importServiceCompileTime);

                try {
                    provider.ModuleProvider.InitializeEventTypes(
                        new EPModuleEventTypeInitServicesImpl(eventTypeCollector, eventTypeResolver));
                }
                catch (Exception e) {
                    throw new EPException(e);
                }
                
                JsonEventTypeUtility.AddJsonUnderlyingClass(moduleTypes, classLoaderParent, null);

                // initialize named windows
                var moduleNamedWindows = new Dictionary<string, NamedWindowMetaData>();
                var namedWindowCollector = new NamedWindowCollectorImpl(moduleNamedWindows);
                try {
                    provider.ModuleProvider.InitializeNamedWindows(
                        new EPModuleNamedWindowInitServicesImpl(namedWindowCollector, eventTypeResolver));
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                // initialize tables
                var moduleTables = new Dictionary<string, TableMetaData>();
                var tableCollector = new TableCollectorImpl(moduleTables);
                try {
                    provider.ModuleProvider.InitializeTables(
                        new EPModuleTableInitServicesImpl(tableCollector, eventTypeResolver));
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                // initialize create-index indexes
                var indexCollector = new IndexCollectorCompileTime(
                    moduleNamedWindows,
                    moduleTables,
                    pathNamedWindows,
                    pathTables);
                try {
                    provider.ModuleProvider.InitializeIndexes(new EPModuleIndexInitServicesImpl(indexCollector));
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                // initialize create-contexts
                var moduleContexts = new Dictionary<string, ContextMetaData>();
                var contextCollector = new ContextCollectorImpl(moduleContexts);
                try {
                    provider.ModuleProvider.InitializeContexts(
                        new EPModuleContextInitServicesImpl(contextCollector, eventTypeResolver));
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                // initialize variables
                var moduleVariables = new Dictionary<string, VariableMetaData>();
                var variableCollector = new VariableCollectorImpl(moduleVariables);
                try {
                    provider.ModuleProvider.InitializeVariables(
                        new EPModuleVariableInitServicesImpl(variableCollector, eventTypeResolver));
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                // initialize module expressions
                var moduleExprDeclareds = new Dictionary<string, ExpressionDeclItem>();
                var exprDeclaredCollector = new ExprDeclaredCollectorCompileTime(moduleExprDeclareds);
                try {
                    provider.ModuleProvider.InitializeExprDeclareds(
                        new EPModuleExprDeclaredInitServicesImpl(exprDeclaredCollector));
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                // initialize module scripts
                var moduleScripts = new Dictionary<NameAndParamNum, ExpressionScriptProvided>();
                var scriptCollector = new ScriptCollectorCompileTime(moduleScripts);
                try {
                    provider.ModuleProvider.InitializeScripts(new EPModuleScriptInitServicesImpl(scriptCollector));
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                // initialize inlined classes
                var moduleClassProvideds = new Dictionary<string, ClassProvided>();
                var classProvidedCollector = new ClassProvidedCollectorCompileTime(moduleClassProvideds, classLoaderParent);
                try {
                    provider.ModuleProvider.InitializeClassProvided(new EPModuleClassProvidedInitServicesImpl(classProvidedCollector));
                } catch (Exception e) {
                    throw new EPException(e);
                }
                
                // save path-visibility event types and named windows to the path
                var deploymentId = "D" + deploymentNumber;
                try {
                    foreach (var type in moduleTypes) {
                        if (type.Value.Metadata.AccessModifier.IsNonPrivateNonTransient()) {
                            pathEventTypes.Add(type.Key, unitModuleName, type.Value, deploymentId);
                        }
                    }

                    foreach (var entry in moduleNamedWindows) {
                        if (entry.Value.EventType.Metadata.AccessModifier.IsNonPrivateNonTransient()) {
                            pathNamedWindows.Add(entry.Key, unitModuleName, entry.Value, deploymentId);
                        }
                    }

                    foreach (var entry in moduleTables) {
                        if (entry.Value.TableVisibility.IsNonPrivateNonTransient()) {
                            pathTables.Add(entry.Key, unitModuleName, entry.Value, deploymentId);
                        }
                    }

                    foreach (var entry in moduleContexts) {
                        if (entry.Value.ContextVisibility.IsNonPrivateNonTransient()) {
                            pathContexts.Add(entry.Key, unitModuleName, entry.Value, deploymentId);
                        }
                    }

                    foreach (var entry in moduleVariables) {
                        if (entry.Value.VariableVisibility.IsNonPrivateNonTransient()) {
                            pathVariables.Add(entry.Key, unitModuleName, entry.Value, deploymentId);
                        }
                    }

                    foreach (var entry in moduleExprDeclareds) {
                        if (entry.Value.Visibility.IsNonPrivateNonTransient()) {
                            pathExprDeclared.Add(entry.Key, unitModuleName, entry.Value, deploymentId);
                        }
                    }

                    foreach (var entry in moduleScripts) {
                        if (entry.Value.Visibility.IsNonPrivateNonTransient()) {
                            pathScript.Add(entry.Key, unitModuleName, entry.Value, deploymentId);
                        }
                    }
                    
                    foreach (var entry in moduleClassProvideds) {
                        if (entry.Value.Visibility.IsNonPrivateNonTransient()) {
                            pathClassProvided.Add(entry.Key, unitModuleName, entry.Value, deploymentId);
                        }
                    }
                }
                catch (PathException ex) {
                    throw new EPCompileException(
                        "Invalid path: " + ex.Message,
                        ex,
                        new EmptyList<EPCompileExceptionItem>());
                }
            }

            var moduleDependencies = new ModuleDependenciesCompileTime();

            // build bean space of public and protected
            var eventTypeCompileTimeResolver = new EventTypeCompileTimeResolver(
                moduleName,
                moduleUses,
                eventTypeCompileRegistry,
                eventTypeRepositoryPreconfigured,
                pathEventTypes,
                moduleDependencies,
                isFireAndForget);

            // build named window registry
            var namedWindowCompileTimeRegistry = new NamedWindowCompileTimeRegistry();
            var namedWindowCompileTimeResolver = new NamedWindowCompileTimeResolverImpl(
                moduleName,
                moduleUses,
                namedWindowCompileTimeRegistry,
                pathNamedWindows,
                moduleDependencies,
                isFireAndForget);

            // build context registry
            var contextCompileTimeRegistry = new ContextCompileTimeRegistry();
            var contextCompileTimeResolver = new ContextCompileTimeResolverImpl(
                moduleName,
                moduleUses,
                contextCompileTimeRegistry,
                pathContexts,
                moduleDependencies,
                isFireAndForget);

            // build variable registry
            var variableCompileTimeRegistry = new VariableCompileTimeRegistry();
            var variableCompileTimeResolver = new VariableCompileTimeResolverImpl(
                moduleName,
                moduleUses,
                variableRepositoryPreconfigured,
                variableCompileTimeRegistry,
                pathVariables,
                moduleDependencies,
                isFireAndForget);

            // build declared-expression registry
            var exprDeclaredCompileTimeRegistry = new ExprDeclaredCompileTimeRegistry();
            var exprDeclaredCompileTimeResolver = new ExprDeclaredCompileTimeResolverImpl(
                moduleName,
                moduleUses,
                exprDeclaredCompileTimeRegistry,
                pathExprDeclared,
                moduleDependencies,
                isFireAndForget);

            // build table-registry
            var localTables = new Dictionary<string, TableMetaData>();
            var tableCompileTimeRegistry = new TableCompileTimeRegistry(localTables);
            var tableCompileTimeResolver = new TableCompileTimeResolverImpl(
                moduleName,
                moduleUses,
                tableCompileTimeRegistry,
                pathTables,
                moduleDependencies,
                isFireAndForget);

            // build script registry
            var scriptCompileTimeRegistry = new ScriptCompileTimeRegistry();
            var scriptCompileTimeResolver = new ScriptCompileTimeResolverImpl(
                moduleName,
                moduleUses,
                scriptCompileTimeRegistry,
                pathScript,
                moduleDependencies,
                isFireAndForget);

            // build classes registry
            var classProvidedCompileTimeRegistry = new ClassProvidedCompileTimeRegistry();
            var classProvidedCompileTimeResolver = new ClassProvidedCompileTimeResolverImpl(
                moduleName,
                moduleUses,
                classProvidedCompileTimeRegistry,
                pathClassProvided,
                moduleDependencies,
                isFireAndForget);

            // view resolution
            var plugInViews = new PluggableObjectCollection();
            plugInViews.AddViews(
                configuration.Compiler.PlugInViews,
                configuration.Compiler.PlugInVirtualDataWindows,
                importServiceCompileTime);
            var viewRegistry = new PluggableObjectRegistryImpl(new[] {ViewEnumHelper.BuiltinViews, plugInViews});
            ViewResolutionService viewResolutionService = new ViewResolutionServiceImpl(viewRegistry);

            var plugInPatternObj = new PluggableObjectCollection();
            plugInPatternObj.AddPatternObjects(configuration.Compiler.PlugInPatternObjects, importServiceCompileTime);
            plugInPatternObj.AddObjects(PatternObjectHelper.BuiltinPatternObjects);
            PatternObjectResolutionService patternResolutionService =
                new PatternObjectResolutionServiceImpl(plugInPatternObj);

            var indexCompileTimeRegistry = new IndexCompileTimeRegistry(new Dictionary<IndexCompileTimeKey, IndexDetailForge>());

            var moduleVisibilityRules = new ModuleAccessModifierServiceImpl(options, configuration.Compiler.ByteCode);

            var databaseConfigServiceCompileTime =
                new DatabaseConfigServiceImpl(
                    container,
                    configuration.Common.DatabaseReferences,
                    importServiceCompileTime);

            var compilerServices = new CompilerServicesImpl();

            var targetHA = configuration.GetType().Name.EndsWith("ConfigurationHA");
            var serdeEventTypeRegistry = new SerdeEventTypeCompileTimeRegistryImpl(targetHA);
            SerdeCompileTimeResolver serdeResolver = targetHA
                ? MakeSerdeResolver(configuration.Compiler.Serde, configuration.Common.TransientConfiguration)
                : SerdeCompileTimeResolverNonHA.INSTANCE;

            return new ModuleCompileTimeServices(
                container,
                compilerServices,
                configuration,
                contextCompileTimeRegistry,
                contextCompileTimeResolver,
                beanEventTypeStemService,
                beanEventTypeFactoryPrivate,
                classProvidedCompileTimeRegistry,
                classProvidedCompileTimeResolver,
                databaseConfigServiceCompileTime,
                importServiceCompileTime,
                exprDeclaredCompileTimeRegistry,
                exprDeclaredCompileTimeResolver,
                eventTypeAvroHandler,
                eventTypeCompileRegistry,
                eventTypeCompileTimeResolver,
                eventTypeRepositoryPreconfigured,
                isFireAndForget,
                indexCompileTimeRegistry,
                moduleDependencies,
                moduleVisibilityRules,
                namedWindowCompileTimeResolver,
                namedWindowCompileTimeRegistry,
                classLoaderParent,
                patternResolutionService,
                scriptCompileTimeRegistry,
                scriptCompileTimeResolver,
                scriptCompiler,
                serdeEventTypeRegistry,
                serdeResolver,
                tableCompileTimeRegistry,
                tableCompileTimeResolver,
                variableCompileTimeRegistry,
                variableCompileTimeResolver,
                viewResolutionService,
                xmlFragmentEventTypeFactory);
        }