Ejemplo n.º 1
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);
        }
 public EventBean AdapterForObjectArray(
     object[] theEvent,
     string eventTypeName)
 {
     var type = eventTypeRepository.GetTypeByName(eventTypeName);
     EventTypeUtility.ValidateTypeObjectArray(eventTypeName, type);
     return new ObjectArrayEventBean(theEvent, type);
 }
Ejemplo n.º 3
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);
        }