Example #1
0
        public StatementContext MakeContext(
            int statementId,
            string statementName,
            string expression,
            StatementType statementType,
            EPServicesContext engineServices,
            IDictionary <string, object> optAdditionalContext,
            bool isFireAndForget,
            Attribute[] annotations,
            EPIsolationUnitServices isolationUnitServices,
            bool stateless,
            StatementSpecRaw statementSpecRaw,
            IList <ExprSubselectNode> subselectNodes,
            bool writesToTables,
            object statementUserObject)
        {
            // Allocate the statement's schedule bucket which stays constant over it's lifetime.
            // The bucket allows callbacks for the same time to be ordered (within and across statements) and thus deterministic.
            var scheduleBucket = engineServices.SchedulingMgmtService.AllocateBucket();

            // Create a lock for the statement
            IReaderWriterLock defaultStatementAgentInstanceLock;

            // For on-delete statements, use the create-named-window statement lock
            var optCreateWindowDesc = statementSpecRaw.CreateWindowDesc;
            var optOnTriggerDesc    = statementSpecRaw.OnTriggerDesc;

            if ((optOnTriggerDesc != null) && (optOnTriggerDesc is OnTriggerWindowDesc))
            {
                var windowName = ((OnTriggerWindowDesc)optOnTriggerDesc).WindowName;
                if (engineServices.TableService.GetTableMetadata(windowName) == null)
                {
                    defaultStatementAgentInstanceLock = engineServices.NamedWindowMgmtService.GetNamedWindowLock(windowName);
                    if (defaultStatementAgentInstanceLock == null)
                    {
                        throw new EPStatementException("Named window or table '" + windowName + "' has not been declared", expression);
                    }
                }
                else
                {
                    defaultStatementAgentInstanceLock = engineServices.StatementLockFactory.GetStatementLock(statementName, annotations, stateless);
                }
            }
            // For creating a named window, save the lock for use with on-delete/on-merge/on-Update etc. statements
            else if (optCreateWindowDesc != null)
            {
                defaultStatementAgentInstanceLock =
                    engineServices.NamedWindowMgmtService.GetNamedWindowLock(optCreateWindowDesc.WindowName);
                if (defaultStatementAgentInstanceLock == null)
                {
                    defaultStatementAgentInstanceLock = engineServices.StatementLockFactory.GetStatementLock(
                        statementName, annotations, false);
                    engineServices.NamedWindowMgmtService.AddNamedWindowLock(
                        optCreateWindowDesc.WindowName, defaultStatementAgentInstanceLock, statementName);
                }
            }
            else
            {
                defaultStatementAgentInstanceLock = engineServices.StatementLockFactory.GetStatementLock(
                    statementName, annotations, stateless);
            }

            StatementMetricHandle stmtMetric = null;

            if (!isFireAndForget)
            {
                stmtMetric = engineServices.MetricsReportingService.GetStatementHandle(statementId, statementName);
            }

            var annotationData    = AnnotationAnalysisResult.AnalyzeAnnotations(annotations);
            var hasVariables      = statementSpecRaw.HasVariables || (statementSpecRaw.CreateContextDesc != null);
            var hasTableAccess    = StatementContextFactoryUtil.DetermineHasTableAccess(subselectNodes, statementSpecRaw, engineServices);
            var epStatementHandle = new EPStatementHandle(
                statementId, statementName, expression, statementType, expression,
                hasVariables, stmtMetric,
                annotationData.Priority,
                annotationData.IsPremptive,
                hasTableAccess,
                engineServices.MultiMatchHandlerFactory.GetDefaultHandler());

            var patternContextFactory = new PatternContextFactoryDefault();

            var optionalCreateNamedWindowName = statementSpecRaw.CreateWindowDesc != null
                ? statementSpecRaw.CreateWindowDesc.WindowName
                : null;
            var viewResolutionService = new ViewResolutionServiceImpl(
                _viewRegistry, optionalCreateNamedWindowName, _systemVirtualDwViewFactory);
            var patternResolutionService =
                new PatternObjectResolutionServiceImpl(_patternObjectClasses);

            var schedulingService = engineServices.SchedulingService;
            var filterService     = engineServices.FilterService;

            if (isolationUnitServices != null)
            {
                filterService     = isolationUnitServices.FilterService;
                schedulingService = isolationUnitServices.SchedulingService;
            }

            var scheduleAudit = AuditEnum.SCHEDULE.GetAudit(annotations);

            if (scheduleAudit != null)
            {
                schedulingService = new SchedulingServiceAudit(
                    engineServices.EngineURI, statementName, schedulingService);
            }

            StatementAIResourceRegistry statementAgentInstanceRegistry = null;
            ContextDescriptor           contextDescriptor = null;
            var optionalContextName = statementSpecRaw.OptionalContextName;

            if (optionalContextName != null)
            {
                contextDescriptor = engineServices.ContextManagementService.GetContextDescriptor(optionalContextName);

                // allocate a per-instance registry of aggregations and prev/prior/subselect
                if (contextDescriptor != null)
                {
                    statementAgentInstanceRegistry = contextDescriptor.AiResourceRegistryFactory.Invoke();
                }
            }

            var countSubexpressions = engineServices.ConfigSnapshot.EngineDefaults.PatternsConfig.MaxSubexpressions != null;
            PatternSubexpressionPoolStmtSvc patternSubexpressionPoolStmtSvc = null;

            if (countSubexpressions)
            {
                var stmtCounter = new PatternSubexpressionPoolStmtHandler();
                patternSubexpressionPoolStmtSvc =
                    new PatternSubexpressionPoolStmtSvc(engineServices.PatternSubexpressionPoolSvc, stmtCounter);
                engineServices.PatternSubexpressionPoolSvc.AddPatternContext(statementName, stmtCounter);
            }

            var countMatchRecogStates = engineServices.ConfigSnapshot.EngineDefaults.MatchRecognizeConfig.MaxStates != null;
            MatchRecognizeStatePoolStmtSvc matchRecognizeStatePoolStmtSvc = null;

            if (countMatchRecogStates && statementSpecRaw.MatchRecognizeSpec != null)
            {
                var stmtCounter = new MatchRecognizeStatePoolStmtHandler();
                matchRecognizeStatePoolStmtSvc = new MatchRecognizeStatePoolStmtSvc(engineServices.MatchRecognizeStatePoolEngineSvc, stmtCounter);
                engineServices.MatchRecognizeStatePoolEngineSvc.AddPatternContext(statementName, stmtCounter);
            }

            AgentInstanceScriptContext defaultAgentInstanceScriptContext = null;

            if (statementSpecRaw.ScriptExpressions != null && !statementSpecRaw.ScriptExpressions.IsEmpty())
            {
                defaultAgentInstanceScriptContext = new AgentInstanceScriptContext();
            }

            // allow a special context controller factory for testing
            var contextControllerFactoryService =
                GetContextControllerFactoryService(annotations);

            // may use resource tracking
            var statementResourceService = new StatementResourceService(optionalContextName != null);
            StatementExtensionSvcContext extensionSvcContext = new ProxyStatementExtensionSvcContext
            {
                ProcStmtResources = () => statementResourceService,
                ProcExtractStatementResourceHolder = resultOfStart => StatementResourceHolderUtil.PopulateHolder(resultOfStart)
            };

            // Create statement context
            return(new StatementContext(
                       _stmtEngineServices,
                       schedulingService,
                       scheduleBucket,
                       epStatementHandle,
                       viewResolutionService,
                       patternResolutionService,
                       extensionSvcContext,
                       new StatementStopServiceImpl(),
                       patternContextFactory,
                       filterService,
                       new StatementResultServiceImpl(
                           statementName,
                           engineServices.StatementLifecycleSvc,
                           engineServices.MetricsReportingService,
                           engineServices.ThreadingService),
                       engineServices.InternalEventEngineRouteDest,
                       annotations,
                       statementAgentInstanceRegistry,
                       defaultStatementAgentInstanceLock,
                       contextDescriptor,
                       patternSubexpressionPoolStmtSvc,
                       matchRecognizeStatePoolStmtSvc,
                       stateless,
                       contextControllerFactoryService,
                       defaultAgentInstanceScriptContext,
                       AggregationServiceFactoryServiceImpl.DEFAULT_FACTORY,
                       engineServices.ScriptingService,
                       writesToTables,
                       statementUserObject,
                       StatementSemiAnonymousTypeRegistryImpl.INSTANCE,
                       annotationData.Priority));
        }
Example #2
0
        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);
        }