/// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="eventAdapterService">is the event wrapper and type service</param>
 /// <param name="eventTypeIdGenerator">The event type id generator.</param>
 /// <param name="engineImportService">for imported aggregation functions and static functions</param>
 /// <param name="variableService">provides access to variable values</param>
 /// <param name="engineSettingsService">some engine settings are writable</param>
 /// <param name="valueAddEventService">Update event handling</param>
 /// <param name="metricReportingService">for metric reporting</param>
 /// <param name="statementEventTypeRef">statement to event type reference holding</param>
 /// <param name="statementVariableRef">statement to variable reference holding</param>
 /// <param name="plugInViews">The plug in views.</param>
 /// <param name="filterService">The filter service.</param>
 /// <param name="patternSubexpressionPoolSvc">The pattern subexpression pool SVC.</param>
 /// <param name="tableService">The table service.</param>
 public ConfigurationOperationsImpl(
     EventAdapterService eventAdapterService,
     EventTypeIdGenerator eventTypeIdGenerator,
     EngineImportService engineImportService,
     VariableService variableService,
     EngineSettingsService engineSettingsService,
     ValueAddEventService valueAddEventService,
     MetricReportingService metricReportingService,
     StatementEventTypeRef statementEventTypeRef,
     StatementVariableRef statementVariableRef,
     PluggableObjectCollection plugInViews,
     FilterService filterService,
     PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc,
     MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc,
     TableService tableService)
 {
     _eventAdapterService              = eventAdapterService;
     _eventTypeIdGenerator             = eventTypeIdGenerator;
     _engineImportService              = engineImportService;
     _variableService                  = variableService;
     _engineSettingsService            = engineSettingsService;
     _valueAddEventService             = valueAddEventService;
     _metricReportingService           = metricReportingService;
     _statementEventTypeRef            = statementEventTypeRef;
     _statementVariableRef             = statementVariableRef;
     _plugInViews                      = plugInViews;
     _filterService                    = filterService;
     _patternSubexpressionPoolSvc      = patternSubexpressionPoolSvc;
     _matchRecognizeStatePoolEngineSvc = matchRecognizeStatePoolEngineSvc;
     _tableService                     = tableService;
 }
Esempio n. 2
0
 static ViewEnumHelper()
 {
     BUILTIN_VIEWS = new PluggableObjectCollection();
     foreach (ViewEnum viewEnum in EnumHelper.GetValues <ViewEnum>())
     {
         BUILTIN_VIEWS.AddObject(
             viewEnum.GetNamespace(), viewEnum.GetName(), viewEnum.GetFactoryType(), PluggableObjectType.VIEW);
     }
 }
Esempio n. 3
0
 static ViewEnumHelper()
 {
     BuiltinViews = new PluggableObjectCollection();
     foreach (var viewEnum in EnumHelper.GetValues<ViewEnum>()) {
         BuiltinViews.AddObject(
             viewEnum.GetNamespace(),
             viewEnum.GetViewName(),
             viewEnum.GetFactoryClass(),
             PluggableObjectType.VIEW);
     }
 }
        public void SetUp()
        {
            IList <ConfigurationPlugInPatternObject> init = new List <ConfigurationPlugInPatternObject>();

            init.Add(MakeGuardSpec("g", "h", typeof(SupportGuardFactory).FullName));
            init.Add(MakeObserverSpec("a", "b", typeof(SupportObserverFactory).FullName));
            PluggableObjectCollection desc = new PluggableObjectCollection();

            desc.AddPatternObjects(init);
            desc.AddObjects(PatternObjectHelper.BuiltinPatternObjects);
            service = new PatternObjectResolutionServiceImpl(desc);
        }
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="viewPlugIns">is the view plug-in object descriptions</param>
        /// <param name="plugInPatternObj">is the pattern plug-in object descriptions</param>
        /// <param name="systemVirtualDWViewFactory">virtual DW factory</param>
        public StatementContextFactoryDefault(
            PluggableObjectCollection viewPlugIns,
            PluggableObjectCollection plugInPatternObj,
            Type systemVirtualDWViewFactory)
        {
            _viewRegistry = new PluggableObjectRegistryImpl(new PluggableObjectCollection[] { ViewEnumHelper.BuiltinViews, viewPlugIns });

            _systemVirtualDwViewFactory = systemVirtualDWViewFactory;

            _patternObjectClasses = new PluggableObjectCollection();
            _patternObjectClasses.AddObjects(plugInPatternObj);
            _patternObjectClasses.AddObjects(PatternObjectHelper.BuiltinPatternObjects);
        }
 private void TryInvalid(IEnumerable <ConfigurationPlugInPatternObject> config)
 {
     try
     {
         var desc = new PluggableObjectCollection();
         desc.AddPatternObjects(config.ToList(), SupportEngineImportServiceFactory.Make(_container));
         _service = new PatternObjectResolutionServiceImpl(_container, desc);
         Assert.Fail();
     }
     catch (ConfigurationException)
     {
         // expected
     }
 }
        public void SetUp()
        {
            _container = SupportContainer.Reset();

            IList <ConfigurationPlugInPatternObject> init = new List <ConfigurationPlugInPatternObject>();

            init.Add(MakeGuardSpec("g", "h", typeof(SupportGuardFactory).FullName));
            init.Add(MakeObserverSpec("a", "b", typeof(SupportObserverFactory).FullName));
            var desc = new PluggableObjectCollection();

            desc.AddPatternObjects(init, SupportEngineImportServiceFactory.Make(_container));
            desc.AddObjects(PatternObjectHelper.BuiltinPatternObjects);
            _service = new PatternObjectResolutionServiceImpl(_container, desc);
        }
 private void TryInvalid(IEnumerable <ConfigurationPlugInPatternObject> config)
 {
     try
     {
         PluggableObjectCollection desc = new PluggableObjectCollection();
         desc.AddPatternObjects(config.ToList());
         service = new PatternObjectResolutionServiceImpl(desc);
         Assert.Fail();
     }
     catch (ConfigurationException ex)
     {
         // expected
     }
 }
Esempio n. 9
0
        static PatternObjectHelper()
        {
            BuiltinPatternObjects = new PluggableObjectCollection();
            foreach (var guardEnum in EnumHelper.GetValues<GuardEnum>()) {
                BuiltinPatternObjects.AddObject(
                    guardEnum.GetNamespace(),
                    guardEnum.GetName(),
                    guardEnum.GetClazz(),
                    PluggableObjectType.PATTERN_GUARD);
            }

            foreach (var observerEnum in EnumHelper.GetValues<ObserverEnum>()) {
                BuiltinPatternObjects.AddObject(
                    observerEnum.GetNamespace(),
                    observerEnum.GetName(),
                    observerEnum.GetImplementationType(),
                    PluggableObjectType.PATTERN_OBSERVER);
            }
        }
Esempio n. 10
0
        private ViewResolutionService CreateService(String[] namespaces, String[] names, String[] classNames)
        {
            List <ConfigurationPlugInView> configs = new List <ConfigurationPlugInView>();

            for (int i = 0; i < namespaces.Length; i++)
            {
                ConfigurationPlugInView config = new ConfigurationPlugInView();
                config.Namespace        = namespaces[i];
                config.Name             = names[i];
                config.FactoryClassName = classNames[i];
                configs.Add(config);
            }

            PluggableObjectCollection desc = new PluggableObjectCollection();

            desc.AddViews(configs, Collections.GetEmptyList <ConfigurationPlugInVirtualDataWindow>(), SupportEngineImportServiceFactory.Make());
            PluggableObjectRegistryImpl registry = new PluggableObjectRegistryImpl(new PluggableObjectCollection[] { desc });

            return(new ViewResolutionServiceImpl(registry, null, null));
        }
Esempio n. 11
0
        // Supplied after construction to avoid circular dependency

        /// <summary>
        /// Constructor - sets up new set of services.
        /// </summary>
        /// <param name="engineURI">is the engine URI</param>
        /// <param name="schedulingService">service to get time and schedule callbacks</param>
        /// <param name="eventAdapterService">service to resolve event types</param>
        /// <param name="engineImportService">is engine imported static func packages and aggregation functions</param>
        /// <param name="engineSettingsService">provides engine settings</param>
        /// <param name="databaseConfigService">service to resolve a database name to database connection factory and configs</param>
        /// <param name="plugInViews">resolves view namespace and name to view factory class</param>
        /// <param name="statementLockFactory">creates statement-level locks</param>
        /// <param name="eventProcessingRWLock">is the engine lock for statement management</param>
        /// <param name="extensionServicesContext">marker interface allows adding additional services</param>
        /// <param name="engineEnvContext">is engine environment/directory information for use with adapters and external env</param>
        /// <param name="statementContextFactory">is the factory to use to create statement context objects</param>
        /// <param name="plugInPatternObjects">resolves plug-in pattern objects</param>
        /// <param name="timerService">is the timer service</param>
        /// <param name="filterService">the filter service</param>
        /// <param name="streamFactoryService">is hooking up filters to streams</param>
        /// <param name="namedWindowMgmtService">The named window MGMT service.</param>
        /// <param name="namedWindowDispatchService">The named window dispatch service.</param>
        /// <param name="variableService">provides access to variable values</param>
        /// <param name="tableService">The table service.</param>
        /// <param name="timeSourceService">time source provider class</param>
        /// <param name="valueAddEventService">handles Update events</param>
        /// <param name="metricsReportingService">for metric reporting</param>
        /// <param name="statementEventTypeRef">statement to event type reference holding</param>
        /// <param name="statementVariableRef">statement to variabke reference holding</param>
        /// <param name="configSnapshot">configuration snapshot</param>
        /// <param name="threadingServiceImpl">engine-level threading services</param>
        /// <param name="internalEventRouter">routing of events</param>
        /// <param name="statementIsolationService">maintains isolation information per statement</param>
        /// <param name="schedulingMgmtService">schedule management for statements</param>
        /// <param name="deploymentStateService">The deployment state service.</param>
        /// <param name="exceptionHandlingService">The exception handling service.</param>
        /// <param name="patternNodeFactory">The pattern node factory.</param>
        /// <param name="eventTypeIdGenerator">The event type id generator.</param>
        /// <param name="statementMetadataFactory">The statement metadata factory.</param>
        /// <param name="contextManagementService">The context management service.</param>
        /// <param name="patternSubexpressionPoolSvc">The pattern subexpression pool SVC.</param>
        /// <param name="matchRecognizeStatePoolEngineSvc">The match recognize state pool engine SVC.</param>
        /// <param name="dataFlowService">The data flow service.</param>
        /// <param name="exprDeclaredService">The expr declared service.</param>
        /// <param name="contextControllerFactoryFactorySvc">The context controller factory factory SVC.</param>
        /// <param name="contextManagerFactoryService">The context manager factory service.</param>
        /// <param name="epStatementFactory">The ep statement factory.</param>
        /// <param name="regexHandlerFactory">The regex handler factory.</param>
        /// <param name="viewableActivatorFactory">The viewable activator factory.</param>
        /// <param name="filterNonPropertyRegisteryService">The filter non property registery service.</param>
        /// <param name="resultSetProcessorHelperFactory">The result set processor helper factory.</param>
        /// <param name="viewServicePreviousFactory">The view service previous factory.</param>
        /// <param name="eventTableIndexService">The event table index service.</param>
        /// <param name="epRuntimeIsolatedFactory">The ep runtime isolated factory.</param>
        /// <param name="filterBooleanExpressionFactory">The filter boolean expression factory.</param>
        /// <param name="dataCacheFactory">The data cache factory.</param>
        /// <param name="multiMatchHandlerFactory">The multi match handler factory.</param>
        /// <param name="namedWindowConsumerMgmtService">The named window consumer MGMT service.</param>
        /// <param name="aggregationFactoryFactory"></param>
        /// <param name="scriptingService">The scripting service.</param>
        public EPServicesContext(
            string engineURI,
            SchedulingServiceSPI schedulingService,
            EventAdapterService eventAdapterService,
            EngineImportService engineImportService,
            EngineSettingsService engineSettingsService,
            DatabaseConfigService databaseConfigService,
            PluggableObjectCollection plugInViews,
            StatementLockFactory statementLockFactory,
            IReaderWriterLock eventProcessingRWLock,
            EngineLevelExtensionServicesContext extensionServicesContext,
            Directory engineEnvContext,
            StatementContextFactory statementContextFactory,
            PluggableObjectCollection plugInPatternObjects,
            TimerService timerService,
            FilterServiceSPI filterService,
            StreamFactoryService streamFactoryService,
            NamedWindowMgmtService namedWindowMgmtService,
            NamedWindowDispatchService namedWindowDispatchService,
            VariableService variableService,
            TableService tableService,
            TimeSourceService timeSourceService,
            ValueAddEventService valueAddEventService,
            MetricReportingServiceSPI metricsReportingService,
            StatementEventTypeRef statementEventTypeRef,
            StatementVariableRef statementVariableRef,
            ConfigurationInformation configSnapshot,
            ThreadingService threadingServiceImpl,
            InternalEventRouterImpl internalEventRouter,
            StatementIsolationService statementIsolationService,
            SchedulingMgmtService schedulingMgmtService,
            DeploymentStateService deploymentStateService,
            ExceptionHandlingService exceptionHandlingService,
            PatternNodeFactory patternNodeFactory,
            EventTypeIdGenerator eventTypeIdGenerator,
            StatementMetadataFactory statementMetadataFactory,
            ContextManagementService contextManagementService,
            PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc,
            MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc,
            DataFlowService dataFlowService,
            ExprDeclaredService exprDeclaredService,
            ContextControllerFactoryFactorySvc contextControllerFactoryFactorySvc,
            ContextManagerFactoryService contextManagerFactoryService,
            EPStatementFactory epStatementFactory,
            RegexHandlerFactory regexHandlerFactory,
            ViewableActivatorFactory viewableActivatorFactory,
            FilterNonPropertyRegisteryService filterNonPropertyRegisteryService,
            ResultSetProcessorHelperFactory resultSetProcessorHelperFactory,
            ViewServicePreviousFactory viewServicePreviousFactory,
            EventTableIndexService eventTableIndexService,
            EPRuntimeIsolatedFactory epRuntimeIsolatedFactory,
            FilterBooleanExpressionFactory filterBooleanExpressionFactory,
            DataCacheFactory dataCacheFactory,
            MultiMatchHandlerFactory multiMatchHandlerFactory,
            NamedWindowConsumerMgmtService namedWindowConsumerMgmtService,
            AggregationFactoryFactory aggregationFactoryFactory,
            ScriptingService scriptingService)
        {
            EngineURI             = engineURI;
            SchedulingService     = schedulingService;
            EventAdapterService   = eventAdapterService;
            EngineImportService   = engineImportService;
            EngineSettingsService = engineSettingsService;
            DatabaseRefService    = databaseConfigService;
            FilterService         = filterService;
            TimerService          = timerService;
            DispatchService       = DispatchServiceProvider.NewService();
            ViewService           = ViewServiceProvider.NewService();
            StreamService         = streamFactoryService;
            PlugInViews           = plugInViews;
            StatementLockFactory  = statementLockFactory;
            EventProcessingRWLock = eventProcessingRWLock;
            EngineLevelExtensionServicesContext = extensionServicesContext;
            EngineEnvContext           = engineEnvContext;
            StatementContextFactory    = statementContextFactory;
            PlugInPatternObjects       = plugInPatternObjects;
            NamedWindowMgmtService     = namedWindowMgmtService;
            NamedWindowDispatchService = namedWindowDispatchService;
            VariableService            = variableService;
            TableService                     = tableService;
            TimeSource                       = timeSourceService;
            ValueAddEventService             = valueAddEventService;
            MetricsReportingService          = metricsReportingService;
            StatementEventTypeRefService     = statementEventTypeRef;
            ConfigSnapshot                   = configSnapshot;
            ThreadingService                 = threadingServiceImpl;
            InternalEventRouter              = internalEventRouter;
            StatementIsolationService        = statementIsolationService;
            SchedulingMgmtService            = schedulingMgmtService;
            StatementVariableRefService      = statementVariableRef;
            DeploymentStateService           = deploymentStateService;
            ExceptionHandlingService         = exceptionHandlingService;
            PatternNodeFactory               = patternNodeFactory;
            EventTypeIdGenerator             = eventTypeIdGenerator;
            StatementMetadataFactory         = statementMetadataFactory;
            ContextManagementService         = contextManagementService;
            PatternSubexpressionPoolSvc      = patternSubexpressionPoolSvc;
            MatchRecognizeStatePoolEngineSvc = matchRecognizeStatePoolEngineSvc;
            DataFlowService                  = dataFlowService;
            ExprDeclaredService              = exprDeclaredService;
            ExpressionResultCacheSharable    = new ExpressionResultCacheService(
                configSnapshot.EngineDefaults.ExecutionConfig.DeclaredExprValueCacheSize);
            ContextControllerFactoryFactorySvc = contextControllerFactoryFactorySvc;
            ContextManagerFactoryService       = contextManagerFactoryService;
            EpStatementFactory                = epStatementFactory;
            RegexHandlerFactory               = regexHandlerFactory;
            ViewableActivatorFactory          = viewableActivatorFactory;
            FilterNonPropertyRegisteryService = filterNonPropertyRegisteryService;
            ResultSetProcessorHelperFactory   = resultSetProcessorHelperFactory;
            ViewServicePreviousFactory        = viewServicePreviousFactory;
            EventTableIndexService            = eventTableIndexService;
            EpRuntimeIsolatedFactory          = epRuntimeIsolatedFactory;
            FilterBooleanExpressionFactory    = filterBooleanExpressionFactory;
            DataCacheFactory               = dataCacheFactory;
            MultiMatchHandlerFactory       = multiMatchHandlerFactory;
            NamedWindowConsumerMgmtService = namedWindowConsumerMgmtService;
            AggregationFactoryFactory      = aggregationFactoryFactory;
            ScriptingService               = scriptingService;
        }
Esempio n. 12
0
 /// <summary>Ctor. </summary>
 /// <param name="patternObjects">is the pattern plug-in objects configured</param>
 public PatternObjectResolutionServiceImpl(PluggableObjectCollection patternObjects)
 {
     _patternObjects = patternObjects;
 }
Esempio n. 13
0
        public EPServicesContext CreateServicesContext(EPServiceProvider epServiceProvider, ConfigurationInformation configSnapshot)
        {
            // Directory for binding resources
            var resourceDirectory = new SimpleServiceDirectory();

            EventTypeIdGenerator eventTypeIdGenerator;

            if (configSnapshot.EngineDefaults.AlternativeContextConfig == null || configSnapshot.EngineDefaults.AlternativeContextConfig.EventTypeIdGeneratorFactory == null)
            {
                eventTypeIdGenerator = new EventTypeIdGeneratorImpl();
            }
            else
            {
                var eventTypeIdGeneratorFactory = TypeHelper.Instantiate <EventTypeIdGeneratorFactory>(
                    configSnapshot.EngineDefaults.AlternativeContextConfig.EventTypeIdGeneratorFactory);
                eventTypeIdGenerator = eventTypeIdGeneratorFactory.Create(new EventTypeIdGeneratorContext(epServiceProvider.URI));
            }

            // Make services that depend on snapshot config entries
            var eventAdapterService = new EventAdapterServiceImpl(eventTypeIdGenerator, configSnapshot.EngineDefaults.EventMetaConfig.AnonymousCacheSize);

            Init(eventAdapterService, configSnapshot);

            // New read-write lock for concurrent event processing
            var eventProcessingRwLock = ReaderWriterLockManager.CreateLock(
                MethodBase.GetCurrentMethod().DeclaringType);

            var timeSourceService     = MakeTimeSource(configSnapshot);
            var schedulingService     = SchedulingServiceProvider.NewService(timeSourceService);
            var schedulingMgmtService = new SchedulingMgmtServiceImpl();
            var engineImportService   = MakeEngineImportService(configSnapshot);
            var engineSettingsService = new EngineSettingsService(configSnapshot.EngineDefaults, configSnapshot.PlugInEventTypeResolutionURIs);
            var databaseConfigService = MakeDatabaseRefService(configSnapshot, schedulingService, schedulingMgmtService);

            var plugInViews = new PluggableObjectCollection();

            plugInViews.AddViews(configSnapshot.PlugInViews, configSnapshot.PlugInVirtualDataWindows);
            var plugInPatternObj = new PluggableObjectCollection();

            plugInPatternObj.AddPatternObjects(configSnapshot.PlugInPatternObjects);

            // exception handling
            ExceptionHandlingService exceptionHandlingService = InitExceptionHandling(
                epServiceProvider.URI,
                configSnapshot.EngineDefaults.ExceptionHandlingConfig,
                configSnapshot.EngineDefaults.ConditionHandlingConfig);

            // Statement context factory
            Type systemVirtualDWViewFactory = null;

            if (configSnapshot.EngineDefaults.AlternativeContextConfig.VirtualDataWindowViewFactory != null)
            {
                try {
                    systemVirtualDWViewFactory = TypeHelper.ResolveType(configSnapshot.EngineDefaults.AlternativeContextConfig.VirtualDataWindowViewFactory);
                    if (!systemVirtualDWViewFactory.IsImplementsInterface(typeof(VirtualDataWindowFactory)))
                    {
                        throw new ConfigurationException("Class " + systemVirtualDWViewFactory.Name + " does not implement the interface " + typeof(VirtualDataWindowFactory).FullName);
                    }
                }
                catch (TypeLoadException e) {
                    throw new ConfigurationException("Failed to look up class " + systemVirtualDWViewFactory);
                }
            }
            StatementContextFactory statementContextFactory = new StatementContextFactoryDefault(plugInViews, plugInPatternObj, systemVirtualDWViewFactory);

            long msecTimerResolution = configSnapshot.EngineDefaults.ThreadingConfig.InternalTimerMsecResolution;

            if (msecTimerResolution <= 0)
            {
                throw new ConfigurationException("Timer resolution configuration not set to a valid value, expecting a non-zero value");
            }
            var timerService = new TimerServiceImpl(epServiceProvider.URI, msecTimerResolution);

            var variableService = new VariableServiceImpl(configSnapshot.EngineDefaults.VariablesConfig.MsecVersionRelease, schedulingService, eventAdapterService, null);

            InitVariables(variableService, configSnapshot.Variables, engineImportService);

            var tableService = new TableServiceImpl();

            var statementLockFactory = new StatementLockFactoryImpl(configSnapshot.EngineDefaults.ExecutionConfig.IsFairlock, configSnapshot.EngineDefaults.ExecutionConfig.IsDisableLocking);
            var streamFactoryService = StreamFactoryServiceProvider.NewService(
                epServiceProvider.URI,
                configSnapshot.EngineDefaults.ViewResourcesConfig.IsShareViews);

            var filterService = FilterServiceProvider.NewService(
                configSnapshot.EngineDefaults.ExecutionConfig.FilterServiceProfile,
                configSnapshot.EngineDefaults.ExecutionConfig.IsAllowIsolatedService);

            var metricsReporting   = new MetricReportingServiceImpl(configSnapshot.EngineDefaults.MetricsReportingConfig, epServiceProvider.URI);
            var namedWindowService = new NamedWindowServiceImpl(
                schedulingService,
                variableService,
                tableService,
                engineSettingsService.EngineSettings.ExecutionConfig.IsPrioritized,
                eventProcessingRwLock,
                exceptionHandlingService,
                configSnapshot.EngineDefaults.LoggingConfig.IsEnableQueryPlan,
                metricsReporting);

            var valueAddEventService = new ValueAddEventServiceImpl();

            valueAddEventService.Init(configSnapshot.RevisionEventTypes, configSnapshot.VariantStreams, eventAdapterService, eventTypeIdGenerator);

            var statementEventTypeRef = new StatementEventTypeRefImpl();
            var statementVariableRef  = new StatementVariableRefImpl(variableService, tableService);

            var threadingService = new ThreadingServiceImpl(
                configSnapshot.EngineDefaults.ThreadingConfig);

            var internalEventRouterImpl = new InternalEventRouterImpl();

            var statementIsolationService = new StatementIsolationServiceImpl();

            DeploymentStateService deploymentStateService = new DeploymentStateServiceImpl();

            StatementMetadataFactory stmtMetadataFactory;

            if (configSnapshot.EngineDefaults.AlternativeContextConfig.StatementMetadataFactory == null)
            {
                stmtMetadataFactory = new StatementMetadataFactoryDefault();
            }
            else
            {
                stmtMetadataFactory = TypeHelper.Instantiate <StatementMetadataFactory>(configSnapshot.EngineDefaults.AlternativeContextConfig.StatementMetadataFactory);
            }

            ContextManagementService contextManagementService = new ContextManagementServiceImpl();

            SchedulableAgentInstanceDirectory schedulableAgentInstanceDirectory = null;     // not required for Non-HA.

            PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc = null;

            if (configSnapshot.EngineDefaults.PatternsConfig.MaxSubexpressions != null)
            {
                patternSubexpressionPoolSvc = new PatternSubexpressionPoolEngineSvc(
                    configSnapshot.EngineDefaults.PatternsConfig.MaxSubexpressions.GetValueOrDefault(),
                    configSnapshot.EngineDefaults.PatternsConfig.IsMaxSubexpressionPreventStart);
            }

            MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc = null;

            if (configSnapshot.EngineDefaults.MatchRecognizeConfig.MaxStates != null)
            {
                matchRecognizeStatePoolEngineSvc = new MatchRecognizeStatePoolEngineSvc(
                    configSnapshot.EngineDefaults.MatchRecognizeConfig.MaxStates.Value,
                    configSnapshot.EngineDefaults.MatchRecognizeConfig.IsMaxStatesPreventStart);
            }

            var scriptingService = new ScriptingServiceImpl();

            scriptingService.DiscoverEngines();

            // New services context
            EPServicesContext services = new EPServicesContext(
                epServiceProvider.URI, schedulingService,
                eventAdapterService, engineImportService, engineSettingsService, databaseConfigService, plugInViews,
                statementLockFactory, eventProcessingRwLock, null, resourceDirectory, statementContextFactory,
                plugInPatternObj, timerService, filterService, streamFactoryService,
                namedWindowService, variableService, tableService, timeSourceService, valueAddEventService, metricsReporting, statementEventTypeRef,
                statementVariableRef, configSnapshot, threadingService, internalEventRouterImpl, statementIsolationService, schedulingMgmtService,
                deploymentStateService, exceptionHandlingService, new PatternNodeFactoryImpl(), eventTypeIdGenerator, stmtMetadataFactory,
                contextManagementService, schedulableAgentInstanceDirectory, patternSubexpressionPoolSvc, matchRecognizeStatePoolEngineSvc,
                new DataFlowServiceImpl(epServiceProvider, new DataFlowConfigurationStateServiceImpl()),
                new ExprDeclaredServiceImpl(),
                new ContextControllerFactoryFactorySvcImpl(),
                new ContextManagerFactoryServiceImpl(),
                new EPStatementFactoryDefault(),
                new RegexHandlerFactoryDefault(),
                new ViewableActivatorFactoryDefault(),
                scriptingService
                );

            // Engine services subset available to statements
            statementContextFactory.StmtEngineServices = services;

            // Circular dependency
            var statementLifecycleSvc = new StatementLifecycleSvcImpl(epServiceProvider, services);

            services.StatementLifecycleSvc = statementLifecycleSvc;

            // Observers to statement events
            statementLifecycleSvc.LifecycleEvent += (s, theEvent) => metricsReporting.Observe(theEvent);

            // Circular dependency
            statementIsolationService.ServicesContext = services;

            return(services);
        }
Esempio n. 14
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="patternObjects">is the pattern plug-in objects configured</param>
 public PatternObjectResolutionServiceImpl(IContainer container, PluggableObjectCollection patternObjects)
 {
     _container      = container;
     _patternObjects = patternObjects;
 }
        public EPServicesContext CreateServicesContext(
            IContainer container,
            EPServiceProvider epServiceProvider,
            ConfigurationInformation configSnapshot)
        {
            var lockManager        = container.LockManager();
            var rwLockManager      = container.RWLockManager();
            var threadLocalManager = container.ThreadLocalManager();
            var resourceManager    = container.ResourceManager();

            // Directory for binding resources
            var resourceDirectory = container.Resolve <Directory>();

            // Engine import service
            var engineImportService = MakeEngineImportService(
                container.Resolve <ClassLoaderProvider>(),
                configSnapshot,
                AggregationFactoryFactoryDefault.INSTANCE,
                epServiceProvider.URI);

            // Event Type Id Generation
            EventTypeIdGenerator eventTypeIdGenerator;

            if (configSnapshot.EngineDefaults.AlternativeContext == null ||
                configSnapshot.EngineDefaults.AlternativeContext.EventTypeIdGeneratorFactory == null)
            {
                eventTypeIdGenerator = new EventTypeIdGeneratorImpl();
            }
            else
            {
                var eventTypeIdGeneratorFactory = TypeHelper.Instantiate <EventTypeIdGeneratorFactory>(
                    configSnapshot.EngineDefaults.AlternativeContext.EventTypeIdGeneratorFactory,
                    engineImportService.GetClassForNameProvider());
                eventTypeIdGenerator = eventTypeIdGeneratorFactory.Create(
                    new EventTypeIdGeneratorContext(epServiceProvider.URI));
            }

            // Make services that depend on snapshot config entries
            EventAdapterAvroHandler avroHandler = EventAdapterAvroHandlerUnsupported.INSTANCE;

            if (configSnapshot.EngineDefaults.EventMeta.AvroSettings.IsEnableAvro)
            {
                try
                {
                    avroHandler = TypeHelper.Instantiate <EventAdapterAvroHandler>(
                        EventAdapterAvroHandlerConstants.HANDLER_IMPL, engineImportService.GetClassForNameProvider());
                }
                catch (Exception e)
                {
                    Log.Debug(
                        "Avro provider {0} not instantiated, not enabling Avro support: {1}",
                        EventAdapterAvroHandlerConstants.HANDLER_IMPL, e.Message);
                }
                try
                {
                    avroHandler.Init(configSnapshot.EngineDefaults.EventMeta.AvroSettings, engineImportService);
                }
                catch (Exception e)
                {
                    throw new ConfigurationException("Failed to initialize Esper-Avro: " + e.Message, e);
                }
            }

            var eventAdapterService = new EventAdapterServiceImpl(
                container,
                eventTypeIdGenerator,
                configSnapshot.EngineDefaults.EventMeta.AnonymousCacheSize,
                avroHandler,
                engineImportService);

            Init(eventAdapterService, configSnapshot, engineImportService, resourceManager);

            // New read-write lock for concurrent event processing
            var eventProcessingRwLock = rwLockManager.CreateLock(GetType());

            var timeSourceService     = MakeTimeSource(configSnapshot);
            var schedulingService     = SchedulingServiceProvider.NewService(timeSourceService, lockManager);
            var schedulingMgmtService = new SchedulingMgmtServiceImpl();
            var engineSettingsService = new EngineSettingsService(
                configSnapshot.EngineDefaults, configSnapshot.PlugInEventTypeResolutionURIs);
            var databaseConfigService = MakeDatabaseRefService(
                configSnapshot, schedulingService, schedulingMgmtService, engineImportService);

            var plugInViews = new PluggableObjectCollection();

            plugInViews.AddViews(
                configSnapshot.PlugInViews, configSnapshot.PlugInVirtualDataWindows, engineImportService);
            var plugInPatternObj = new PluggableObjectCollection();

            plugInPatternObj.AddPatternObjects(configSnapshot.PlugInPatternObjects, engineImportService);

            // exception handling
            var exceptionHandlingService = InitExceptionHandling(
                epServiceProvider.URI, configSnapshot.EngineDefaults.ExceptionHandling,
                configSnapshot.EngineDefaults.ConditionHandling, engineImportService);

            // Statement context factory
            Type systemVirtualDWViewFactory = null;

            if (configSnapshot.EngineDefaults.AlternativeContext.VirtualDataWindowViewFactory != null)
            {
                try
                {
                    systemVirtualDWViewFactory =
                        engineImportService.GetClassForNameProvider()
                        .ClassForName(configSnapshot.EngineDefaults.AlternativeContext.VirtualDataWindowViewFactory);
                    if (!TypeHelper.IsImplementsInterface(systemVirtualDWViewFactory, typeof(VirtualDataWindowFactory)))
                    {
                        throw new ConfigurationException(
                                  "Type " + systemVirtualDWViewFactory.Name + " does not implement the interface " +
                                  typeof(VirtualDataWindowFactory).Name);
                    }
                }
                catch (TypeLoadException)
                {
                    throw new ConfigurationException("Failed to look up class " + systemVirtualDWViewFactory);
                }
            }
            var statementContextFactory = new StatementContextFactoryDefault(
                plugInViews, plugInPatternObj, systemVirtualDWViewFactory);

            var msecTimerResolution = configSnapshot.EngineDefaults.Threading.InternalTimerMsecResolution;

            if (msecTimerResolution <= 0)
            {
                throw new ConfigurationException(
                          "Timer resolution configuration not set to a valid value, expecting a non-zero value");
            }
            var timerService = new TimerServiceImpl(epServiceProvider.URI, msecTimerResolution);

            var variableService = new VariableServiceImpl(
                container,
                configSnapshot.EngineDefaults.Variables.MsecVersionRelease,
                schedulingService,
                eventAdapterService,
                null);

            InitVariables(variableService, configSnapshot.Variables, engineImportService);

            var tableService = new TableServiceImpl(container);

            var statementLockFactory = new StatementLockFactoryImpl(
                rwLockManager,
                configSnapshot.EngineDefaults.Execution.IsFairlock,
                configSnapshot.EngineDefaults.Execution.IsDisableLocking
                );

            var streamFactoryService = StreamFactoryServiceProvider.NewService(
                epServiceProvider.URI, configSnapshot.EngineDefaults.ViewResources.IsShareViews);
            var filterService = FilterServiceProvider.NewService(
                lockManager,
                rwLockManager,
                configSnapshot.EngineDefaults.Execution.FilterServiceProfile,
                configSnapshot.EngineDefaults.Execution.IsAllowIsolatedService);
            var metricsReporting = new MetricReportingServiceImpl(
                configSnapshot.EngineDefaults.MetricsReporting,
                epServiceProvider.URI,
                rwLockManager);
            var namedWindowMgmtService = new NamedWindowMgmtServiceImpl(
                configSnapshot.EngineDefaults.Logging.IsEnableQueryPlan,
                metricsReporting);
            var namedWindowDispatchService = new NamedWindowDispatchServiceImpl(
                schedulingService, variableService, tableService,
                engineSettingsService.EngineSettings.Execution.IsPrioritized, eventProcessingRwLock,
                exceptionHandlingService, metricsReporting, threadLocalManager);

            var valueAddEventService = new ValueAddEventServiceImpl(lockManager);

            valueAddEventService.Init(
                configSnapshot.RevisionEventTypes, configSnapshot.VariantStreams, eventAdapterService,
                eventTypeIdGenerator);

            var statementEventTypeRef = new StatementEventTypeRefImpl(rwLockManager);
            var statementVariableRef  = new StatementVariableRefImpl(
                variableService, tableService, namedWindowMgmtService, rwLockManager);

            var threadingService = new ThreadingServiceImpl(configSnapshot.EngineDefaults.Threading);

            var internalEventRouterImpl = new InternalEventRouterImpl(epServiceProvider.URI);

            var statementIsolationService = new StatementIsolationServiceImpl();

            var deploymentStateService = new DeploymentStateServiceImpl(lockManager);

            StatementMetadataFactory stmtMetadataFactory;

            if (configSnapshot.EngineDefaults.AlternativeContext.StatementMetadataFactory == null)
            {
                stmtMetadataFactory = new StatementMetadataFactoryDefault();
            }
            else
            {
                stmtMetadataFactory = TypeHelper.Instantiate <StatementMetadataFactory>(
                    configSnapshot.EngineDefaults.AlternativeContext.StatementMetadataFactory,
                    engineImportService.GetClassForNameProvider());
            }

            var contextManagementService = new ContextManagementServiceImpl();

            PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc = null;

            if (configSnapshot.EngineDefaults.Patterns.MaxSubexpressions != null)
            {
                patternSubexpressionPoolSvc =
                    new PatternSubexpressionPoolEngineSvc(
                        configSnapshot.EngineDefaults.Patterns.MaxSubexpressions.Value,
                        configSnapshot.EngineDefaults.Patterns.IsMaxSubexpressionPreventStart);
            }

            MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc = null;

            if (configSnapshot.EngineDefaults.MatchRecognize.MaxStates != null)
            {
                matchRecognizeStatePoolEngineSvc =
                    new MatchRecognizeStatePoolEngineSvc(
                        configSnapshot.EngineDefaults.MatchRecognize.MaxStates.Value,
                        configSnapshot.EngineDefaults.MatchRecognize.IsMaxStatesPreventStart);
            }

            var scriptingService = new ScriptingServiceImpl();

            scriptingService.DiscoverEngines();

            // New services context

            var services = new EPServicesContext(
                container, epServiceProvider.URI,
                schedulingService,
                eventAdapterService,
                engineImportService,
                engineSettingsService,
                databaseConfigService,
                plugInViews,
                statementLockFactory,
                eventProcessingRwLock,
                null,
                resourceDirectory,
                statementContextFactory,
                plugInPatternObj,
                timerService,
                filterService,
                streamFactoryService,
                namedWindowMgmtService,
                namedWindowDispatchService,
                variableService,
                tableService,
                timeSourceService,
                valueAddEventService,
                metricsReporting,
                statementEventTypeRef,
                statementVariableRef,
                configSnapshot,
                threadingService,
                internalEventRouterImpl,
                statementIsolationService,
                schedulingMgmtService,
                deploymentStateService,
                exceptionHandlingService,
                new PatternNodeFactoryImpl(),
                eventTypeIdGenerator,
                stmtMetadataFactory,
                contextManagementService,
                patternSubexpressionPoolSvc,
                matchRecognizeStatePoolEngineSvc,
                new DataFlowServiceImpl(epServiceProvider, new DataFlowConfigurationStateServiceImpl(), lockManager),
                new ExprDeclaredServiceImpl(lockManager),
                new ContextControllerFactoryFactorySvcImpl(),
                new ContextManagerFactoryServiceImpl(),
                new EPStatementFactoryDefault(),
                new RegexHandlerFactoryDefault(container),
                new ViewableActivatorFactoryDefault(),
                new FilterNonPropertyRegisteryServiceImpl(),
                new ResultSetProcessorHelperFactoryImpl(),
                new ViewServicePreviousFactoryImpl(),
                new EventTableIndexServiceImpl(),
                new EPRuntimeIsolatedFactoryImpl(),
                new FilterBooleanExpressionFactoryImpl(),
                new DataCacheFactory(),
                new MultiMatchHandlerFactoryImpl(),
                NamedWindowConsumerMgmtServiceImpl.INSTANCE,
                AggregationFactoryFactoryDefault.INSTANCE,
                scriptingService
                );

            // Engine services subset available to statements
            statementContextFactory.StmtEngineServices = services;

            // Circular dependency
            var statementLifecycleSvc = new StatementLifecycleSvcImpl(epServiceProvider, services);

            services.StatementLifecycleSvc = statementLifecycleSvc;

            // Observers to statement events
            statementLifecycleSvc.LifecycleEvent += (s, theEvent) => metricsReporting.Observe(theEvent);

            // Circular dependency
            statementIsolationService.SetEpServicesContext(services);

            return(services);
        }
Esempio n. 16
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);
        }