private static void BuildAvroType(
     EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
     string eventTypeName,
     ConfigurationCommonEventTypeAvro config,
     EventTypeAvroHandler eventTypeAvroHandler,
     EventBeanTypedEventFactory eventBeanTypedEventFactory)
 {
     var metadata = new EventTypeMetadata(
         eventTypeName,
         null,
         EventTypeTypeClass.APPLICATION,
         EventTypeApplicationType.AVRO,
         NameAccessModifier.PRECONFIGURED,
         EventTypeBusModifier.NONBUS,
         false,
         new EventTypeIdPair(CRC32Util.ComputeCRC32(eventTypeName), -1));
     var avroSuperTypes = EventTypeUtility.GetSuperTypesDepthFirst(
         config.SuperTypes,
         EventUnderlyingType.AVRO,
         eventTypeRepositoryPreconfigured);
     var newEventType = eventTypeAvroHandler.NewEventTypeFromSchema(
         metadata,
         eventBeanTypedEventFactory,
         config,
         avroSuperTypes.First,
         avroSuperTypes.Second);
     eventTypeRepositoryPreconfigured.AddType(newEventType);
 }
Пример #2
0
        internal static FragmentEventType GetFragmentEventTypeForField(
            Schema fieldSchema,
            string moduleName,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeAvroHandler eventTypeAvroHandler,
            AvroEventTypeFragmentTypeCache fragmentTypeCache)
        {
            Schema recordSchema;
            var indexed = false;
            if (fieldSchema.Tag == Schema.Type.Record) {
                recordSchema = fieldSchema;
            }
            else if (fieldSchema.Tag == Schema.Type.Array &&
                     fieldSchema.AsArraySchema().ItemSchema.Tag == Schema.Type.Record) {
                recordSchema = fieldSchema.AsArraySchema().ItemSchema;
                indexed = true;
            }
            else {
                return null;
            }

            var cached = fragmentTypeCache.Get(recordSchema.Name);
            if (cached != null) {
                return new FragmentEventType(cached, indexed, false);
            }

            var metadata = new EventTypeMetadata(
                recordSchema.Name,
                moduleName,
                EventTypeTypeClass.STREAM,
                EventTypeApplicationType.AVRO,
                NameAccessModifier.TRANSIENT,
                EventTypeBusModifier.NONBUS,
                false,
                EventTypeIdPair.Unassigned());
            var config = new ConfigurationCommonEventTypeAvro();
            config.AvroSchema = recordSchema;

            var fragmentType = eventTypeAvroHandler.NewEventTypeFromSchema(
                metadata,
                eventBeanTypedEventFactory,
                config,
                null,
                null);

            fragmentTypeCache.Add(recordSchema.Name, fragmentType);
            return new FragmentEventType(fragmentType, indexed, false);
        }