public static ClassLoaderProvider ResolveClassLoader(
     ClassLoaderProvider classLoaderProvider,
     IDictionary<string, object> transientConfiguration)
 {
     return Resolve<ClassLoaderProvider>(
         transientConfiguration, 
         classLoaderProvider,
         ClassLoaderProviderDefault.NAME,
         typeof (ClassLoaderProvider));
 }
Exemplo n.º 2
0
 public static EngineImportServiceImpl Make(ClassLoaderProvider classLoaderProvider)
 {
     return(new EngineImportServiceImpl(
                true, true, true, false, null,
                TimeZoneInfo.Local,
                TimeAbacusMilliseconds.INSTANCE,
                ConfigurationEngineDefaults.ThreadingProfile.NORMAL, null,
                AggregationFactoryFactoryDefault.INSTANCE,
                false, "default", null,
                classLoaderProvider));
 }
Exemplo n.º 3
0
        public static EventPropertyGetter Compile(
            this ICodegenContext codegenContext,
            string engineURI,
            ClassLoaderProvider classLoaderProvider,
            EventPropertyGetterSPI getterSPI,
            string propertyExpression)
        {
            var get      = getterSPI.CodegenEventBeanGet(Ref("bean"), codegenContext);
            var exists   = getterSPI.CodegenEventBeanExists(Ref("bean"), codegenContext);
            var fragment = getterSPI.CodegenEventBeanFragment(Ref("bean"), codegenContext);

            var singleBeanParam = CodegenNamedParam.From(typeof(EventBean), "bean");

            // For: public object Get(EventBean eventBean) ;
            // For: public bool IsExistsProperty(EventBean eventBean);
            // For: public object GetFragment(EventBean eventBean) ;
            var getMethod = new CodegenMethod(typeof(object), "Get", singleBeanParam, null);

            getMethod.Statements.MethodReturn(get);
            var isExistsPropertyMethod = new CodegenMethod(typeof(bool), "IsExistsProperty", singleBeanParam, null);

            isExistsPropertyMethod.Statements.MethodReturn(exists);
            var fragmentMethod = new CodegenMethod(typeof(object), "GetFragment", singleBeanParam, null);

            fragmentMethod.Statements.MethodReturn(fragment);

            var clazz = new CodegenClass(
                "com.espertech.esper.codegen.uri_" + engineURI,
                typeof(EventPropertyGetter).Name + "_" + CodeGenerationIDGenerator.GenerateClass(),
                typeof(EventPropertyGetter),
                codegenContext.Members,
                new [] { getMethod, isExistsPropertyMethod, fragmentMethod },
                codegenContext.Methods
                );

            string debugInfo = null;

            if (codegenContext.IsDebugEnabled)
            {
                debugInfo = getterSPI.GetType().FullName + " for property '" + propertyExpression + "'";
            }

            return(codegenContext.Compiler.Compile(
                       clazz, classLoaderProvider, typeof(EventPropertyGetter), debugInfo));
        }
Exemplo n.º 4
0
        public EventPropertyGetter Compile(
            ICodegenClass clazz,
            ClassLoaderProvider classLoaderProvider,
            Type interfaceClass,
            string classLevelComment)
        {
            // build members and namespaces
            var memberSet = new LinkedHashSet <ICodegenMember>(clazz.Members);
            var classes   = clazz.GetReferencedClasses();
            var imports   = CompileImports(classes);

            // generate code
            var code = GenerateCode(imports, clazz, memberSet, classLevelComment);

            var version = LanguageVersion.Latest;
            var options = new CSharpParseOptions(
                languageVersion: version,
                documentationMode: DocumentationMode.None,
                kind: SourceCodeKind.Regular,
                preprocessorSymbols: null);

            var syntaxTree = CSharpSyntaxTree.ParseText(code, options);

            _compilation = _compilation.AddSyntaxTrees(syntaxTree);

            using (var stream = new MemoryStream())
            {
                var emitResult = _compilation.Emit(stream);
                if (emitResult.Success)
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    var assembly = Assembly.Load(stream.ToArray());
                }
                else
                {
                    var failures = emitResult.Diagnostics.Where(diagnostic =>
                                                                diagnostic.IsWarningAsError ||
                                                                diagnostic.Severity == DiagnosticSeverity.Error);
                }
            }
            throw new NotImplementedException();
        }
Exemplo n.º 5
0
        public static EventAdapterService Allocate(
            IContainer container,
            ClassLoaderProvider classLoaderProvider)
        {
            EventAdapterAvroHandler avroHandler = EventAdapterAvroHandlerUnsupported.INSTANCE;

            try
            {
                avroHandler = TypeHelper.Instantiate <EventAdapterAvroHandler>(
                    EventAdapterAvroHandlerConstants.HANDLER_IMPL, ClassForNameProviderDefault.INSTANCE);
            }
            catch
            {
            }

            return(new EventAdapterServiceImpl(
                       container,
                       new EventTypeIdGeneratorImpl(), 5, avroHandler,
                       SupportEngineImportServiceFactory.Make(classLoaderProvider)));
        }
Exemplo n.º 6
0
 public EngineImportServiceImpl(
     bool allowExtendedAggregationFunc,
     bool isUdfCache,
     bool isDuckType,
     bool sortUsingCollator,
     MathContext optionalDefaultMathContext,
     TimeZoneInfo timeZone,
     TimeAbacus timeAbacus,
     ConfigurationEngineDefaults.ThreadingProfile threadingProfile,
     IDictionary<string, object> transientConfiguration,
     AggregationFactoryFactory aggregationFactoryFactory,
     bool isCodegenEventPropertyGetters,
     string engineURI,
     ICodegenContext context,
     ClassLoaderProvider classLoaderProvider)
 {
     _imports = new List<AutoImportDesc>();
     _annotationImports = new List<AutoImportDesc>(2);
     _aggregationFunctions = new Dictionary<string, ConfigurationPlugInAggregationFunction>();
     _aggregationAccess = new List<Pair<ISet<string>, ConfigurationPlugInAggregationMultiFunction>>();
     _singleRowFunctions = new Dictionary<string, EngineImportSingleRowDesc>();
     _methodInvocationRef = new Dictionary<string, ConfigurationMethodRef>();
     _allowExtendedAggregationFunc = allowExtendedAggregationFunc;
     IsUdfCache = isUdfCache;
     IsDuckType = isDuckType;
     IsSortUsingCollator = sortUsingCollator;
     DefaultMathContext = optionalDefaultMathContext;
     TimeZone = timeZone;
     TimeAbacus = timeAbacus;
     ThreadingProfile = threadingProfile;
     _transientConfiguration = transientConfiguration;
     AggregationFactoryFactory = aggregationFactoryFactory;
     _advancedIndexProviders = new LinkedHashMap<string, AdvancedIndexFactoryProvider>();
     _advancedIndexProviders.Put("pointregionquadtree", new AdvancedIndexFactoryProviderPointRegionQuadTree());
     _advancedIndexProviders.Put("mxcifquadtree", new AdvancedIndexFactoryProviderMXCIFQuadTree());
     IsCodegenEventPropertyGetters = isCodegenEventPropertyGetters;
     _engineURI = engineURI;
     _context = context;
     _classLoaderProvider = classLoaderProvider;
 }
        /// <summary>
        /// Constructs the auto import service.
        /// </summary>
        /// <param name="classLoaderProvider">The class loader provider.</param>
        /// <param name="configSnapshot">config INFO</param>
        /// <param name="aggregationFactoryFactory">factory of aggregation service provider</param>
        /// <param name="engineURI">The engine URI.</param>
        /// <returns>
        /// service
        /// </returns>
        /// <exception cref="ConfigurationException">Invalid time-source time unit of " + timeUnit + ", expected millis or micros
        /// or
        /// Error configuring engine: " + ex.Message</exception>
        internal static EngineImportService MakeEngineImportService(
            ClassLoaderProvider classLoaderProvider,
            ConfigurationInformation configSnapshot,
            AggregationFactoryFactory aggregationFactoryFactory,
            String engineURI)
        {
            TimeUnit   timeUnit = configSnapshot.EngineDefaults.TimeSource.TimeUnit;
            TimeAbacus timeAbacus;

            if (timeUnit == TimeUnit.MILLISECONDS)
            {
                timeAbacus = TimeAbacusMilliseconds.INSTANCE;
            }
            else if (timeUnit == TimeUnit.MICROSECONDS)
            {
                timeAbacus = TimeAbacusMicroseconds.INSTANCE;
            }
            else
            {
                throw new ConfigurationException(
                          "Invalid time-source time unit of " + timeUnit + ", expected millis or micros");
            }

            var codegenGetters = configSnapshot.EngineDefaults.Execution.CodeGeneration.IsEnablePropertyGetter;

            if (codegenGetters)
            {
                if (CheckPackageName("uri_" + engineURI) == PackageName.INVALID)
                {
                    throw new ConfigurationException("Invalid engine URI '" + engineURI + "', code generation requires an engine URI that is a valid Java-language identifier and may not contain Java language keywords");
                }
            }

            var expression          = configSnapshot.EngineDefaults.Expression;
            var engineImportService = new EngineImportServiceImpl(
                expression.IsExtendedAggregation,
                expression.IsUdfCache, expression.IsDuckTyping,
                configSnapshot.EngineDefaults.Language.IsSortUsingCollator,
                configSnapshot.EngineDefaults.Expression.MathContext,
                configSnapshot.EngineDefaults.Expression.TimeZone, timeAbacus,
                configSnapshot.EngineDefaults.Execution.ThreadingProfile,
                configSnapshot.TransientConfiguration,
                aggregationFactoryFactory,
                codegenGetters,
                engineURI,
                null,
                classLoaderProvider);

            engineImportService.AddMethodRefs(configSnapshot.MethodInvocationReferences);

            // Add auto-imports
            try
            {
                foreach (var importName in configSnapshot.Imports)
                {
                    engineImportService.AddImport(importName);
                }

                foreach (var importName in configSnapshot.AnnotationImports)
                {
                    engineImportService.AddAnnotationImport(importName);
                }

                foreach (var config in configSnapshot.PlugInAggregationFunctions)
                {
                    engineImportService.AddAggregation(config.Name, config);
                }

                foreach (var config in configSnapshot.PlugInAggregationMultiFunctions)
                {
                    engineImportService.AddAggregationMultiFunction(config);
                }

                foreach (var config in configSnapshot.PlugInSingleRowFunctions)
                {
                    engineImportService.AddSingleRow(
                        config.Name, config.FunctionClassName, config.FunctionMethodName, config.ValueCache,
                        config.FilterOptimizable, config.IsRethrowExceptions, config.EventTypeName);
                }
            }
            catch (EngineImportException ex)
            {
                throw new ConfigurationException("Error configuring engine: " + ex.Message, ex);
            }

            return(engineImportService);
        }
Exemplo n.º 8
0
 public static void Reset(
     ILockManager lockManager,
     ClassLoaderProvider classLoaderProvider)
 {
     _eventAdapterService = Allocate(lockManager, classLoaderProvider);
 }