public void NewType(EventType type)
        {
            try {
                EventTypeUtility.ValidateModifiers(type.Name, type.Metadata.BusModifier, type.Metadata.AccessModifier);
            } catch (ExprValidationException e) {
                throw new ArgumentException(e.Message, e);
            }
            
            if (type.Metadata.AccessModifier == NameAccessModifier.PRECONFIGURED) {
                if (type.Metadata.ApplicationType != EventTypeApplicationType.XML) {
                    throw new ArgumentException("Preconfigured-visibility is not allowed here");
                }

                _eventTypeRepositoryPreconfigured.AddType(type);
            }

            if (_moduleTypesAdded.ContainsKey(type.Name)) {
                throw new ArgumentException("Event type '" + type.Name + "' has already been added by the module");
            }

            if (type.Metadata.AccessModifier == NameAccessModifier.PRIVATE ||
                type.Metadata.AccessModifier == NameAccessModifier.INTERNAL ||
                type.Metadata.AccessModifier == NameAccessModifier.PUBLIC) {
                _moduleTypesAdded.Put(type.Name, type);
            }

            // We allow private types to register multiple times, the first one counts (i.e. rollup with multiple select-clauses active)
            if (!_newTypesAdded.ContainsKey(type.Name)) {
                _newTypesAdded.Put(type.Name, type);
            }
            else {
                throw new ArgumentException("Event type '" + type.Name + "' has already been added by the module");
            }
        }
Exemplo n.º 2
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);
        }