Beispiel #1
0
        public static void BuildBeanTypes(
            BeanEventTypeStemService beanEventTypeStemService,
            EventTypeRepositoryImpl repo,
            IDictionary<string, Type> beanTypes,
            BeanEventTypeFactoryPrivate privateFactory,
            IDictionary<string, ConfigurationCommonEventTypeBean> configs)
        {
            if (beanTypes.IsEmpty()) {
                beanTypes = new Dictionary<string, Type>();
            }

            AddPredefinedBeanEventTypes(beanTypes);

            foreach (var beanType in beanTypes) {
                if (repo.GetTypeByName(beanType.Key) == null) {
                    BuildPublicBeanType(
                        beanEventTypeStemService,
                        repo,
                        beanType.Key,
                        beanType.Value,
                        privateFactory,
                        configs);
                }
            }
        }
Beispiel #2
0
        private static ISet<EventType> GetDeepSupertypes(
            ISet<Type> superTypes,
            BeanEventTypeStemService beanEventTypeStemService,
            EventTypeRepository repo,
            BeanEventTypeFactoryPrivate privateFactory,
            IDictionary<string, ConfigurationCommonEventTypeBean> configs)
        {
            if (superTypes == null || superTypes.IsEmpty()) {
                return new EmptySet<EventType>();
            }

            var supers = new LinkedHashSet<EventType>();
            foreach (var clazz in superTypes) {
                supers.Add(GetBuildSuperType(clazz, beanEventTypeStemService, repo, privateFactory, configs));
            }

            return supers;
        }
Beispiel #3
0
        public static EventType GetBuildSuperType(
            Type clazz,
            BeanEventTypeStemService beanEventTypeStemService,
            EventTypeRepository repo,
            BeanEventTypeFactoryPrivate privateFactory,
            IDictionary<string, ConfigurationCommonEventTypeBean> configs)
        {
            var existingSuperTypeNames = beanEventTypeStemService.PublicClassToTypeNames.Get(clazz);
            if (existingSuperTypeNames != null) {
                var eventType = repo.GetTypeByName(existingSuperTypeNames[0]);
                if (eventType != null) {
                    return eventType;
                }
            }

            BuildPublicBeanType(beanEventTypeStemService, repo, clazz.FullName, clazz, privateFactory, configs);
            return repo.GetTypeByName(clazz.FullName);
        }
Beispiel #4
0
        private static EventType[] GetSuperTypes(
            Type[] superTypes,
            BeanEventTypeStemService beanEventTypeStemService,
            EventTypeRepository repo,
            BeanEventTypeFactoryPrivate privateFactory,
            IDictionary<string, ConfigurationCommonEventTypeBean> configs)
        {
            if (superTypes == null || superTypes.Length == 0) {
                return null;
            }

            var types = new EventType[superTypes.Length];
            for (var i = 0; i < types.Length; i++) {
                types[i] = GetBuildSuperType(superTypes[i], beanEventTypeStemService, repo, privateFactory, configs);
            }

            return types;
        }
Beispiel #5
0
        private static void BuildPublicBeanType(
            BeanEventTypeStemService beanEventTypeStemService,
            EventTypeRepository repo,
            string eventTypeName,
            Type clazz,
            BeanEventTypeFactoryPrivate privateFactory,
            IDictionary<string, ConfigurationCommonEventTypeBean> configs)
        {
            // check existing type
            var existingType = repo.GetTypeByName(eventTypeName);
            if (existingType != null) {
                if (existingType.Metadata.ApplicationType != EventTypeApplicationType.CLASS) {
                    throw new ConfigurationException(
                        "Event type named '" +
                        eventTypeName +
                        "' has already been declared with differing underlying type information: Class " +
                        existingType.UnderlyingType.FullName +
                        " versus " +
                        clazz.Name);
                }

                var beanEventType = (BeanEventType) existingType;
                if (beanEventType.UnderlyingType != clazz) {
                    throw new ConfigurationException(
                        "Event type named '" +
                        eventTypeName +
                        "' has already been declared with differing underlying type information: Class " +
                        existingType.UnderlyingType.FullName +
                        " versus " +
                        beanEventType.UnderlyingType);
                }

                return;
            }

            var optionalConfig = configs.Get(eventTypeName);

            // check-allocate bean-stem
            var stem = beanEventTypeStemService.GetCreateStem(clazz, optionalConfig);

            // metadata
            var publicId = CRC32Util.ComputeCRC32(eventTypeName);

            var metadata = new EventTypeMetadata(
                eventTypeName,
                null,
                EventTypeTypeClass.STREAM,
                EventTypeApplicationType.CLASS,
                NameAccessModifier.PRECONFIGURED,
                EventTypeBusModifier.NONBUS,
                false,
                new EventTypeIdPair(publicId, -1));

            // supertypes
            var superTypes = GetSuperTypes(stem.SuperTypes, beanEventTypeStemService, repo, privateFactory, configs);
            var deepSuperTypes = GetDeepSupertypes(
                stem.DeepSuperTypes,
                beanEventTypeStemService,
                repo,
                privateFactory,
                configs);

            // bean type
            var startTS = optionalConfig == null ? null : optionalConfig.StartTimestampPropertyName;
            var endTS = optionalConfig == null ? null : optionalConfig.EndTimestampPropertyName;
            var eventType = privateFactory.EventTypeFactory.CreateBeanType(
                stem,
                metadata,
                privateFactory,
                superTypes,
                deepSuperTypes,
                startTS,
                endTS);

            repo.AddType(eventType);
        }