Exemple #1
0
        private static Type FindInterfaceImplementation(
            IDictionary <string, Object> properties,
            Type topClass,
            EngineImportService engineImportService)
        {
            var message = "Failed to find implementation for interface " + Name.Clean(topClass);

            // Allow to populate the special "class" field
            if (!properties.ContainsKey(CLASS_PROPERTY_NAME))
            {
                throw new ExprValidationException(
                          message + ", for interfaces please specified the '" + CLASS_PROPERTY_NAME +
                          "' field that provides the class name either as a simple class name or fully qualified");
            }

            Type clazz     = null;
            var  className = (string)properties.Get(CLASS_PROPERTY_NAME);

            try
            {
                clazz = TypeHelper.GetClassForName(className, engineImportService.GetClassForNameProvider());
            }
            catch (TypeLoadException)
            {
                if (!className.Contains("."))
                {
                    className = topClass.Namespace + "." + className;
                    try
                    {
                        clazz = TypeHelper.GetClassForName(className, engineImportService.GetClassForNameProvider());
                    }
                    catch (TypeLoadException)
                    {
                    }
                }

                if (clazz == null)
                {
                    throw new ExprValidationPropertyException(message + ", could not find class by name '" + className + "'");
                }
            }

            if (!TypeHelper.IsSubclassOrImplementsInterface(clazz, topClass))
            {
                throw new ExprValidationException(
                          message + ", class " + clazz.GetCleanName() +
                          " does not implement the interface");
            }
            return(clazz);
        }
Exemple #2
0
        private ICollection <Type> GetClassSet(string[] classIdentifiers, EngineImportService engineImportService)
        {
            var classList = new HashSet <Type>();

            foreach (String className in classIdentifiers)
            {
                // try the primitive names including "string"
                var clazz = TypeHelper.GetPrimitiveTypeForName(className.Trim());
                if (clazz != null)
                {
                    classList.Add(clazz);
                    classList.Add(clazz.GetBoxedType());
                    continue;
                }

                // try to look up the class, not a primitive type name
                try
                {
                    clazz = TypeHelper.GetClassForName(className.Trim(), engineImportService.GetClassForNameProvider());
                }
                catch (TypeLoadException e)
                {
                    throw new ExprValidationException("Class as listed in is function by name '" + className + "' cannot be loaded", e);
                }

                // Add primitive and boxed types, or type itself if not built-in
                classList.Add(clazz.GetPrimitiveType());
                classList.Add(clazz.GetBoxedType());
            }
            return(classList);
        }
        public void Init(ConfigurationEngineDefaults.AvroSettings avroSettings, EngineImportService engineImportService)
        {
            _avroSettings = avroSettings;

            if (avroSettings.TypeRepresentationMapperClass != null)
            {
                _optionalTypeMapper = TypeHelper.Instantiate <TypeRepresentationMapper>(
                    avroSettings.TypeRepresentationMapperClass,
                    engineImportService.GetClassForNameProvider());
            }

            if (avroSettings.ObjectValueTypeWidenerFactoryClass != null)
            {
                _optionalWidenerFactory = TypeHelper.Instantiate <ObjectValueTypeWidenerFactory>(
                    avroSettings.ObjectValueTypeWidenerFactoryClass,
                    engineImportService.GetClassForNameProvider());
            }
        }
Exemple #4
0
        public void AddEventType(string eventTypeName, Properties typeMap)
        {
            CheckTableExists(eventTypeName);
            IDictionary <string, Object> types = TypeHelper.GetClassObjectFromPropertyTypeNames(
                typeMap, _engineImportService.GetClassForNameProvider());

            try {
                _eventAdapterService.AddNestableMapType(eventTypeName, types, null, false, true, true, false, false);
            } catch (EventAdapterException t) {
                throw new ConfigurationException(t.Message, t);
            }
        }
Exemple #5
0
        private void HandleAddPluggableObject(
            String factoryClassName,
            String @namespace,
            String name,
            PluggableObjectType type,
            Object optionalCustomConfig,
            EngineImportService engineImportService)
        {
            if (factoryClassName == null)
            {
                throw new ConfigurationException("Factory class name has not been supplied for object '" + name + "'");
            }
            if (@namespace == null)
            {
                throw new ConfigurationException("Namespace name has not been supplied for object '" + name + "'");
            }
            if (name == null)
            {
                throw new ConfigurationException("Name has not been supplied for object in namespace '" + @namespace + "'");
            }

            try
            {
                var clazz = engineImportService.GetClassForNameProvider().ClassForName(factoryClassName);

                var namespaceMap = Pluggables.Get(@namespace);
                if (namespaceMap == null)
                {
                    namespaceMap = new Dictionary <String, Pair <Type, PluggableObjectEntry> >();
                    Pluggables.Put(@namespace, namespaceMap);
                }
                namespaceMap.Put(
                    name,
                    new Pair <Type, PluggableObjectEntry>(clazz, new PluggableObjectEntry(type, optionalCustomConfig)));
            }
            catch (TypeLoadException e)
            {
                throw new ConfigurationException("View factory class " + factoryClassName + " could not be loaded", e);
            }
        }
        internal static ExceptionHandlingService InitExceptionHandling(
            string engineURI,
            ConfigurationEngineDefaults.ExceptionHandlingConfig exceptionHandling,
            ConfigurationEngineDefaults.ConditionHandlingConfig conditionHandling,
            EngineImportService engineImportService)
        {
            IList <ExceptionHandler> exceptionHandlers;

            if (exceptionHandling.HandlerFactories == null || exceptionHandling.HandlerFactories.IsEmpty())
            {
                exceptionHandlers = Collections.GetEmptyList <ExceptionHandler>();
            }
            else
            {
                exceptionHandlers = new List <ExceptionHandler>();
                var context = new ExceptionHandlerFactoryContext(engineURI);
                foreach (var className in exceptionHandling.HandlerFactories)
                {
                    try
                    {
                        var factory = TypeHelper.Instantiate <ExceptionHandlerFactory>(
                            className, engineImportService.GetClassForNameProvider());
                        var handler = factory.GetHandler(context);
                        if (handler == null)
                        {
                            Log.Warn(
                                "Exception handler factory '" + className +
                                "' returned a null handler, skipping factory");
                            continue;
                        }
                        exceptionHandlers.Add(handler);
                    }
                    catch (Exception ex)
                    {
                        throw new ConfigurationException(
                                  "Exception initializing exception handler from exception handler factory '" + className +
                                  "': " + ex.Message, ex);
                    }
                }
            }

            IList <ConditionHandler> conditionHandlers;

            if (conditionHandling.HandlerFactories == null || conditionHandling.HandlerFactories.IsEmpty())
            {
                conditionHandlers = Collections.GetEmptyList <ConditionHandler>();
            }
            else
            {
                conditionHandlers = new List <ConditionHandler>();
                var context = new ConditionHandlerFactoryContext(engineURI);
                foreach (var className in conditionHandling.HandlerFactories)
                {
                    try
                    {
                        var factory = TypeHelper.Instantiate <ConditionHandlerFactory>(
                            className, engineImportService.GetClassForNameProvider());
                        var handler = factory.GetHandler(context);
                        if (handler == null)
                        {
                            Log.Warn(
                                "Condition handler factory '" + className +
                                "' returned a null handler, skipping factory");
                            continue;
                        }
                        conditionHandlers.Add(handler);
                    }
                    catch (Exception ex)
                    {
                        throw new ConfigurationException(
                                  "Exception initializing exception handler from exception handler factory '" + className +
                                  "': " + ex.Message, ex);
                    }
                }
            }

            return(new ExceptionHandlingService(
                       engineURI,
                       exceptionHandlers,
                       conditionHandlers));
        }
Exemple #7
0
        public static ExprNode TryResolveAsAggregation(
            EngineImportService engineImportService,
            bool distinct,
            string functionName,
            LazyAllocatedMap <ConfigurationPlugInAggregationMultiFunction, PlugInAggregationMultiFunctionFactory> plugInAggregations,
            string engineURI)
        {
            try
            {
                AggregationFunctionFactory aggregationFactory =
                    engineImportService.ResolveAggregationFactory(functionName);
                return(new ExprPlugInAggNode(distinct, aggregationFactory, functionName));
            }
            catch (EngineImportUndefinedException)
            {
                // Not an aggregation function
            }
            catch (EngineImportException e)
            {
                throw new IllegalStateException("Error resolving aggregation: " + e.Message, e);
            }

            // try plug-in aggregation multi-function
            ConfigurationPlugInAggregationMultiFunction config =
                engineImportService.ResolveAggregationMultiFunction(functionName);

            if (config != null)
            {
                PlugInAggregationMultiFunctionFactory factory = plugInAggregations.Map.Get(config);
                if (factory == null)
                {
                    factory = TypeHelper.Instantiate <PlugInAggregationMultiFunctionFactory>(config.MultiFunctionFactoryClassName, engineImportService.GetClassForNameProvider());
                    plugInAggregations.Map.Put(config, factory);
                }
                factory.AddAggregationFunction(
                    new PlugInAggregationMultiFunctionDeclarationContext(
                        functionName.ToLowerInvariant(), distinct, engineURI, config));
                return(new ExprPlugInAggMultiFunctionNode(distinct, config, factory, functionName));
            }

            // try built-in expanded set of aggregation functions
            return(engineImportService.ResolveAggExtendedBuiltin(functionName, distinct));
        }