示例#1
0
        public void RegisterXMLNewType(
            EventTypeMetadata metadata,
            ConfigurationCommonEventTypeXMLDOM config)
        {
            SchemaModel schemaModel = null;
            if ((config.SchemaResource != null) || (config.SchemaText != null)) {
                try {
                    schemaModel = XSDSchemaMapper.LoadAndMap(
                        config.SchemaResource,
                        config.SchemaText,
                        _container.ResourceManager());
                }
                catch (Exception ex) {
                    throw new EPException(ex.Message, ex);
                }
            }

            EventType eventType = _eventTypeFactory.CreateXMLType(
                metadata,
                config,
                schemaModel,
                null,
                metadata.Name,
                _beanEventTypeFactory,
                _xmlFragmentEventTypeFactory,
                _eventTypeNameResolver);
            HandleRegister(eventType);

            if (eventType is SchemaXMLEventType) {
                _xmlFragmentEventTypeFactory.AddRootType((SchemaXMLEventType) eventType);
            }
        }
        private static void AddXMLDOMType(
            EventTypeRepositoryImpl repo,
            string eventTypeName,
            ConfigurationCommonEventTypeXMLDOM detail,
            SchemaModel schemaModel,
            BeanEventTypeFactory beanEventTypeFactory,
            XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory)
        {
            if (detail.RootElementName == null) {
                throw new EventAdapterException("Required root element name has not been supplied");
            }

            var existingType = repo.GetTypeByName(eventTypeName);
            if (existingType != null) {
                var message = "Event type named '" +
                              eventTypeName +
                              "' has already been declared with differing column name or type information";
                throw new ConfigurationException(message);
            }

            var propertyAgnostic = detail.SchemaResource == null && detail.SchemaText == null;
            var metadata = new EventTypeMetadata(
                eventTypeName,
                null,
                EventTypeTypeClass.STREAM,
                EventTypeApplicationType.XML,
                NameAccessModifier.PRECONFIGURED,
                EventTypeBusModifier.BUS,
                propertyAgnostic,
                new EventTypeIdPair(CRC32Util.ComputeCRC32(eventTypeName), -1));
            var type = beanEventTypeFactory.EventTypeFactory.CreateXMLType(
                metadata,
                detail,
                schemaModel,
                null,
                metadata.Name,
                beanEventTypeFactory,
                xmlFragmentEventTypeFactory,
                repo);
            repo.AddType(type);

            if (type is SchemaXMLEventType) {
                xmlFragmentEventTypeFactory.AddRootType((SchemaXMLEventType) type);
            }
        }