Ejemplo n.º 1
0
        /// <summary>
        ///     Constructor takes a class as an argument.
        /// </summary>
        /// <param name="clazz">is the class of a java bean or other POJO</param>
        /// <param name="optionalLegacyDef">optional configuration supplying legacy event type information</param>
        /// <param name="eventAdapterService">factory for event beans and event types</param>
        /// <param name="metadata">event type metadata</param>
        /// <param name="eventTypeId">type id</param>
        public BeanEventType(
            EventTypeMetadata metadata,
            int eventTypeId,
            Type clazz,
            EventAdapterService eventAdapterService,
            ConfigurationEventTypeLegacy optionalLegacyDef)
        {
            _metadata = metadata;
            _clazz = clazz;
            _eventAdapterService = eventAdapterService;
            _optionalLegacyDef = optionalLegacyDef;
            _eventTypeId = eventTypeId;

            if (optionalLegacyDef != null)
            {
                _factoryMethodName = optionalLegacyDef.FactoryMethod;
                _copyMethodName = optionalLegacyDef.CopyMethod;
                _propertyResolutionStyle = optionalLegacyDef.PropertyResolutionStyle;
            }
            else
            {
                _propertyResolutionStyle = eventAdapterService.BeanEventTypeFactory.DefaultPropertyResolutionStyle;
            }
            _propertyGetterCache = new Dictionary<string, EventPropertyGetter>();

            Initialize(false, eventAdapterService.EngineImportService);

            EventTypeUtility.TimestampPropertyDesc desc = EventTypeUtility.ValidatedDetermineTimestampProps(
                this, 
                optionalLegacyDef == null ? null : optionalLegacyDef.StartTimestampPropertyName,
                optionalLegacyDef == null ? null : optionalLegacyDef.EndTimestampPropertyName, _superTypes);
            _startTimestampPropertyName = desc.Start;
            _endTimestampPropertyName = desc.End;
        }
Ejemplo n.º 2
0
 public BeanEventTypeStem(
     Type clazz,
     ConfigurationCommonEventTypeBean optionalLegacyDef,
     string[] propertyNames,
     IDictionary<string, PropertyInfo> simpleProperties,
     IDictionary<string, PropertyStem> mappedPropertyDescriptors,
     IDictionary<string, PropertyStem> indexedPropertyDescriptors,
     Type[] superTypes,
     ISet<Type> deepSuperTypes,
     PropertyResolutionStyle propertyResolutionStyle,
     IDictionary<string, IList<PropertyInfo>> simpleSmartPropertyTable,
     IDictionary<string, IList<PropertyInfo>> indexedSmartPropertyTable,
     IDictionary<string, IList<PropertyInfo>> mappedSmartPropertyTable,
     IList<EventPropertyDescriptor> propertyDescriptors,
     IDictionary<string, EventPropertyDescriptor> propertyDescriptorMap)
 {
     Clazz = clazz;
     OptionalLegacyDef = optionalLegacyDef;
     PropertyNames = propertyNames;
     SimpleProperties = simpleProperties;
     MappedPropertyDescriptors = mappedPropertyDescriptors;
     IndexedPropertyDescriptors = indexedPropertyDescriptors;
     SuperTypes = superTypes;
     DeepSuperTypes = deepSuperTypes;
     PropertyResolutionStyle = propertyResolutionStyle;
     SimpleSmartPropertyTable = simpleSmartPropertyTable;
     IndexedSmartPropertyTable = indexedSmartPropertyTable;
     MappedSmartPropertyTable = mappedSmartPropertyTable;
     PropertyDescriptors = propertyDescriptors;
     PropertyDescriptorMap = propertyDescriptorMap;
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Looks up and returns a cached indexed property's descriptor.
        /// </summary>
        /// <param name="propertyName">to look up</param>
        /// <returns>property descriptor</returns>
        public InternalEventPropDescriptor GetIndexedProperty(string propertyName)
        {
            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.CASE_SENSITIVE))
            {
                return _indexedPropertyDescriptors.Get(propertyName);
            }
            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.CASE_INSENSITIVE))
            {
                IList<SimplePropertyInfo> propertyInfos = _indexedSmartPropertyTable.Get(propertyName.ToLowerInvariant());
                return propertyInfos != null
                    ? propertyInfos[0].Descriptor
                    : null;
            }
            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.DISTINCT_CASE_INSENSITIVE))
            {
                IList<SimplePropertyInfo> propertyInfos = _indexedSmartPropertyTable.Get(propertyName.ToLowerInvariant());
                if (propertyInfos != null)
                {
                    if (propertyInfos.Count != 1)
                    {
                        throw new EPException(
                            "Unable to determine which property to use for \"" + propertyName +
                            "\" because more than one property matched");
                    }

                    return propertyInfos[0].Descriptor;
                }
            }
            return null;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Looks up and returns a cached mapped property's descriptor.
        /// </summary>
        /// <param name="propertyName">to look up</param>
        /// <returns>property descriptor</returns>
        public PropertyStem GetMappedProperty(string propertyName)
        {
            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.CASE_SENSITIVE)) {
                return Stem.MappedPropertyDescriptors.Get(propertyName);
            }

            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.CASE_INSENSITIVE)) {
                var propertyInfos = Stem.MappedSmartPropertyTable.Get(propertyName.ToLowerInvariant());
                return propertyInfos?[0].Descriptor;
            }

            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.DISTINCT_CASE_INSENSITIVE)) {
                var propertyInfos = Stem.MappedSmartPropertyTable.Get(propertyName.ToLowerInvariant());
                if (propertyInfos != null) {
                    if (propertyInfos.Count != 1) {
                        throw new EPException(
                            "Unable to determine which property to use for \"" +
                            propertyName +
                            "\" because more than one property matched");
                    }

                    return propertyInfos[0].Descriptor;
                }
            }

            return null;
        }
 /// <summary>
 ///     Ctor.
 /// </summary>
 public ConfigurationCommonEventTypeMeta()
 {
     _classPropertyResolutionStyle = PropertyResolutionStyle.DEFAULT;
     _defaultAccessorStyle = AccessorStyle.NATIVE;
     _defaultEventRepresentation = EventUnderlyingTypeExtensions.GetDefault();
     _avroSettings = new AvroSettingsConfig();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Finds the property.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="resolutionStyle">if set to <c>true</c> [is case sensitive].</param>
        /// <returns></returns>
        public SimpleMagicPropertyInfo ResolveProperty(string propertyName, PropertyResolutionStyle resolutionStyle)
        {
            switch (resolutionStyle)
            {
            case PropertyResolutionStyle.CASE_SENSITIVE:
                do
                {
                    var property = _csPropertyTable.Get(propertyName);
                    if (property != null)
                    {
                        return(property);
                    }
                    if (_parent != null)
                    {
                        return(_parent.ResolveProperty(propertyName, resolutionStyle));
                    }
                    return(null);
                } while (false);

            case PropertyResolutionStyle.CASE_INSENSITIVE:
                do
                {
                    var property = _ciPropertyTable.Get(propertyName.ToUpper());
                    if (property != null)
                    {
                        return(property);
                    }
                    if (_parent != null)
                    {
                        return(_parent.ResolveProperty(propertyName, resolutionStyle));
                    }
                    return(null);
                } while (false);

            case PropertyResolutionStyle.DISTINCT_CASE_INSENSITIVE:
                do
                {
                    var property = _ciPropertyTable.Get(propertyName.ToUpper());
                    if (property != null)
                    {
                        if (property.IsUnique)
                        {
                            return(property);
                        }

                        throw new EPException("Unable to determine which property to use for \"" + propertyName +
                                              "\" because more than one property matched");
                    }

                    if (_parent != null)
                    {
                        return(_parent.ResolveProperty(propertyName, resolutionStyle));
                    }
                    return(null);
                } while (false);
            }

            return(null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Search of the type to find a property.
        /// </summary>
        /// <param name="propertyName">The name.</param>
        /// <param name="resolutionStyle">The resolution style.</param>
        /// <returns></returns>
        public MethodInfo ResolvePropertyMethod(
            string propertyName,
            PropertyResolutionStyle resolutionStyle)
        {
            var property = ResolveProperty(propertyName, resolutionStyle) as SimpleMagicPropertyInfo;

            return(property?.GetMethod);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="typesPerObject">shareable collection that this adapter writes tofor caching bean types per class</param>
 /// <param name="eventAdapterService">factory for event beans and event types</param>
 /// <param name="eventTypeIdGenerator">The event type id generator.</param>
 public BeanEventAdapter(IDictionary <Type, BeanEventType> typesPerObject,
                         EventAdapterService eventAdapterService,
                         EventTypeIdGenerator eventTypeIdGenerator)
 {
     _typesPerObject                 = typesPerObject;
     _typesPerObjectLock             = LockManager.CreateLock(GetType());
     _typeToLegacyConfigs            = new Dictionary <String, ConfigurationEventTypeLegacy>();
     _defaultPropertyResolutionStyle = PropertyResolutionStyle.DEFAULT;
     _eventAdapterService            = eventAdapterService;
     _eventTypeIdGenerator           = eventTypeIdGenerator;
 }
Ejemplo n.º 9
0
 public BeanEventTypeStemService(
     IDictionary<Type, IList<string>> publicClassToTypeNames,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     PropertyResolutionStyle defaultPropertyResolutionStyle,
     AccessorStyle defaultAccessorStyle)
 {
     PublicClassToTypeNames = publicClassToTypeNames;
     EventBeanTypedEventFactory = eventBeanTypedEventFactory;
     this._defaultPropertyResolutionStyle = defaultPropertyResolutionStyle;
     this._defaultAccessorStyle = defaultAccessorStyle;
 }
Ejemplo n.º 10
0
        public BeanEventTypeStemBuilder(
            ConfigurationCommonEventTypeBean optionalConfig,
            PropertyResolutionStyle defaultPropertyResolutionStyle)
        {
            _optionalConfig = optionalConfig;

            if (optionalConfig != null) {
                _propertyResolutionStyle = optionalConfig.PropertyResolutionStyle;
            }
            else {
                _propertyResolutionStyle = defaultPropertyResolutionStyle;
            }

            _smartResolutionStyle = _propertyResolutionStyle.Equals(PropertyResolutionStyle.CASE_INSENSITIVE) ||
                                   _propertyResolutionStyle.Equals(PropertyResolutionStyle.DISTINCT_CASE_INSENSITIVE);
        }
Ejemplo n.º 11
0
        private SimplePropertyInfo GetSimplePropertyInfo(string propertyName)
        {
            SimplePropertyInfo propertyInfo;
            IList<SimplePropertyInfo> simplePropertyInfoList;

            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.CASE_SENSITIVE))
            {
                return _simpleProperties.Get(propertyName);
            }
            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.CASE_INSENSITIVE))
            {
                propertyInfo = _simpleProperties.Get(propertyName);
                if (propertyInfo != null)
                {
                    return propertyInfo;
                }

                simplePropertyInfoList = _simpleSmartPropertyTable.Get(propertyName.ToLowerInvariant());
                return
                    simplePropertyInfoList != null
                        ? simplePropertyInfoList[0]
                        : null;
            }
            if (PropertyResolutionStyle.Equals(PropertyResolutionStyle.DISTINCT_CASE_INSENSITIVE))
            {
                propertyInfo = _simpleProperties.Get(propertyName);
                if (propertyInfo != null)
                {
                    return propertyInfo;
                }

                simplePropertyInfoList = _simpleSmartPropertyTable.Get(propertyName.ToLowerInvariant());
                if (simplePropertyInfoList != null)
                {
                    if (simplePropertyInfoList.Count != 1)
                    {
                        throw new EPException(
                            "Unable to determine which property to use for \"" + propertyName +
                            "\" because more than one property matched");
                    }

                    return simplePropertyInfoList[0];
                }
            }

            return null;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Resolves the complex property.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="resolutionStyle">The resolution style.</param>
        /// <returns></returns>
        public MagicPropertyInfo ResolveComplexProperty(string propertyName, PropertyResolutionStyle resolutionStyle)
        {
            int indexOfDot = propertyName.IndexOf('.');

            if (indexOfDot != -1)
            {
                var head             = propertyName.Substring(0, indexOfDot);
                var tail             = propertyName.Substring(indexOfDot + 1);
                var rootProperty     = ResolveProperty(head, resolutionStyle);
                var rootPropertyType = GetCachedType(rootProperty.PropertyType);
                if (rootPropertyType == null)
                {
                    return(null);
                }

                var tailProperty = rootPropertyType.ResolveProperty(tail, resolutionStyle);
                return(new DynamicMagicPropertyInfo(rootProperty, tailProperty));
            }

            return(ResolveProperty(propertyName, resolutionStyle));
        }