public static void buildVariantStreams(EventTypeRepositoryImpl repo, Map<String, ConfigurationCommonVariantStream> variantStreams, EventTypeFactory eventTypeFactory) { for (Map.Entry<String, ConfigurationCommonVariantStream> entry : variantStreams.entrySet()) { if (repo.getTypeByName(entry.getKey()) != null) { continue; } addVariantStream(entry.getKey(), entry.getValue(), repo, eventTypeFactory); } }
private EventType resolvePreconfigured(String typeName) { EventType eventType = publics.getTypeByName(typeName); if (eventType == null) { return null; } moduleDependencies.addPublicEventType(typeName); return eventType; }
public static void buildAvroTypes(EventTypeRepositoryImpl repo, Map<String, ConfigurationCommonEventTypeAvro> eventTypesAvro, EventTypeAvroHandler eventTypeAvroHandler, EventBeanTypedEventFactory eventBeanTypedEventFactory) { for (Map.Entry<String, ConfigurationCommonEventTypeAvro> entry : eventTypesAvro.entrySet()) { if (repo.getTypeByName(entry.getKey()) != null) { continue; } buildAvroType(repo, entry.getKey(), entry.getValue(), eventTypeAvroHandler, eventBeanTypedEventFactory); } }
public EventType getEventTypePreconfigured(String eventTypeName) { return services.getEventTypeRepositoryBus().getTypeByName(eventTypeName); }
public static void buildBeanTypes(BeanEventTypeStemService beanEventTypeStemService, EventTypeRepositoryImpl repo, Map<String, Class> beanTypes, BeanEventTypeFactoryPrivate privateFactory, Map<String, ConfigurationCommonEventTypeBean> configs) { if (beanTypes.isEmpty()) { beanTypes = new HashMap<>(); } addPredefinedBeanEventTypes(beanTypes); for (Map.Entry<String, Class> beanType : beanTypes.entrySet()) { if (repo.getTypeByName(beanType.getKey()) != null) { continue; } buildPublicBeanType(beanEventTypeStemService, repo, beanType.getKey(), beanType.getValue(), privateFactory, configs); } }
public static void buildOATypes(EventTypeRepositoryImpl repo, Map<String, ConfigurationCommonEventTypeObjectArray> objectArrayTypeConfigurations, Map<String, Map<String, Object>> nestableObjectArrayNames, BeanEventTypeFactory beanEventTypeFactory, ClasspathImportService classpathImportService) { List<String> creationOrder = EventTypeRepositoryUtil.getCreationOrder(Collections.emptySet(), nestableObjectArrayNames.keySet(), objectArrayTypeConfigurations); for (String objectArrayName : creationOrder) { if (repo.getTypeByName(objectArrayName) != null) { continue; } ConfigurationCommonEventTypeObjectArray objectArrayConfig = objectArrayTypeConfigurations.get(objectArrayName); Map<String, Object> propertyTypes = nestableObjectArrayNames.get(objectArrayName); propertyTypes = resolveClassesForStringPropertyTypes(propertyTypes, classpathImportService); LinkedHashMap<String, Object> propertyTypesCompiled = EventTypeUtility.compileMapTypeProperties(propertyTypes, repo); addNestableObjectArrayType(objectArrayName, propertyTypesCompiled, objectArrayConfig, beanEventTypeFactory, repo); } }
public static void buildXMLTypes(EventTypeRepositoryImpl repo, Map<String, ConfigurationCommonEventTypeXMLDOM> eventTypesXMLDOM, BeanEventTypeFactory beanEventTypeFactory, XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory, ClasspathImportService classpathImportService) { // Add from the configuration the XML DOM names and type def for (Map.Entry<String, ConfigurationCommonEventTypeXMLDOM> entry : eventTypesXMLDOM.entrySet()) { if (repo.getTypeByName(entry.getKey()) != null) { continue; } SchemaModel schemaModel = null; if ((entry.getValue().getSchemaResource() != null) || (entry.getValue().getSchemaText() != null)) { try { schemaModel = XSDSchemaMapper.loadAndMap(entry.getValue().getSchemaResource(), entry.getValue().getSchemaText(), classpathImportService); } catch (Exception ex) { throw new ConfigurationException(ex.getMessage(), ex); } } try { addXMLDOMType(repo, entry.getKey(), entry.getValue(), schemaModel, beanEventTypeFactory, xmlFragmentEventTypeFactory); } catch (Throwable ex) { throw new ConfigurationException(ex.getMessage(), ex); } } }
public static void buildMapTypes(EventTypeRepositoryImpl repo, Map<String, ConfigurationCommonEventTypeMap> mapTypeConfigurations, Map<String, Properties> mapTypes, Map<String, Map<String, Object>> nestableMapEvents, BeanEventTypeFactory beanEventTypeFactory, ClasspathImportService classpathImportService) { List<String> creationOrder = EventTypeRepositoryUtil.getCreationOrder(mapTypes.keySet(), nestableMapEvents.keySet(), mapTypeConfigurations); for (String mapName : creationOrder) { if (repo.getTypeByName(mapName) != null) { continue; } ConfigurationCommonEventTypeMap mapConfig = mapTypeConfigurations.get(mapName); Properties propertiesUnnested = mapTypes.get(mapName); if (propertiesUnnested != null) { Map<String, Object> propertyTypes = createPropertyTypes(propertiesUnnested, classpathImportService); LinkedHashMap<String, Object> propertyTypesCompiled = EventTypeUtility.compileMapTypeProperties(propertyTypes, repo); addNestableMapType(mapName, propertyTypesCompiled, mapConfig, repo, beanEventTypeFactory, repo); } Map<String, Object> propertiesNestable = nestableMapEvents.get(mapName); if (propertiesNestable != null) { LinkedHashMap<String, Object> propertiesNestableCompiled = EventTypeUtility.compileMapTypeProperties(propertiesNestable, repo); addNestableMapType(mapName, propertiesNestableCompiled, mapConfig, repo, beanEventTypeFactory, repo); } } }
/** * Validate the variant stream definition. * * @param variantStreamname the stream name * @param variantStreamConfig the configuration information * @param repo the event types * @return specification for variant streams */ private static VariantSpec validateVariantStream(String variantStreamname, ConfigurationCommonVariantStream variantStreamConfig, EventTypeRepositoryImpl repo) { if (variantStreamConfig.getTypeVariance() == ConfigurationCommonVariantStream.TypeVariance.PREDEFINED) { if (variantStreamConfig.getVariantTypeNames().isEmpty()) { throw new ConfigurationException("Invalid variant stream configuration, no event type name has been added and default type variance requires at least one type, for name '" + variantStreamname + "'"); } } Set<EventType> types = new LinkedHashSet<EventType>(); for (String typeName : variantStreamConfig.getVariantTypeNames()) { EventType type = repo.getTypeByName(typeName); if (type == null) { throw new ConfigurationException("Event type by name '" + typeName + "' could not be found for use in variant stream configuration by name '" + variantStreamname + "'"); } types.add(type); } EventType[] eventTypes = types.toArray(new EventType[types.size()]); return new VariantSpec(eventTypes, variantStreamConfig.getTypeVariance()); }
public static EventTypeIdPair getTypeIdForName(StatementContext statementContext, String eventTypeName) { EventType type = statementContext.getEventTypeRepositoryPreconfigured().getTypeByName(eventTypeName); if (type == null) { fail("Type by name '" + eventTypeName + "' not found as a public type"); } return type.getMetadata().getEventTypeIdPair(); }
private EventType findTypeMayNull(String eventTypeName) { EventType eventType = eventTypeRepositoryPreconfigured.getTypeByName(eventTypeName); if (eventType != null) { return eventType; } try { eventType = pathEventTypes.getAnyModuleExpectSingle(eventTypeName, null).getFirst(); } catch (PathException ex) { throw new EPException("Failed to obtain event type '" + eventTypeName + "': " + ex.getMessage(), ex); } return eventType; } }
private static void addNestableObjectArrayType(String eventTypeName, LinkedHashMap<String, Object> propertyTypesMayHavePrimitive, ConfigurationCommonEventTypeObjectArray optionalConfig, BeanEventTypeFactory beanEventTypeFactory, EventTypeRepositoryImpl repo) { if (optionalConfig != null && optionalConfig.getSuperTypes().size() > 1) { throw new EventAdapterException(ConfigurationCommonEventTypeObjectArray.SINGLE_SUPERTYPE_MSG); } LinkedHashMap<String, Object> propertyTypes = EventTypeUtility.getPropertyTypesNonPrimitive(propertyTypesMayHavePrimitive); EventTypeMetadata metadata = new EventTypeMetadata(eventTypeName, null, EventTypeTypeClass.APPLICATION, EventTypeApplicationType.OBJECTARR, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, false, new EventTypeIdPair(CRC32Util.computeCRC32(eventTypeName), -1)); String[] superTypes = null; if (optionalConfig != null && optionalConfig.getSuperTypes() != null && !optionalConfig.getSuperTypes().isEmpty()) { superTypes = optionalConfig.getSuperTypes().toArray(new String[optionalConfig.getSuperTypes().size()]); } ObjectArrayEventType newEventType = beanEventTypeFactory.getEventTypeFactory().createObjectArray(metadata, propertyTypes, superTypes, optionalConfig != null ? optionalConfig.getStartTimestampPropertyName() : null, optionalConfig != null ? optionalConfig.getEndTimestampPropertyName() : null, beanEventTypeFactory, repo); EventType existingType = repo.getTypeByName(eventTypeName); if (existingType != null) { // The existing type must be the same as the type createdStatement if (newEventType.equalsCompareType(existingType) != null) { ExprValidationException message = newEventType.compareEquals(existingType); throw new EPException("Event type named '" + eventTypeName + "' has already been declared with differing column name or type information: " + message.getMessage(), message); } // Since it's the same, return the existing type return; } repo.addType(newEventType); }
private static void addNestableMapType(String eventTypeName, LinkedHashMap<String, Object> propertyTypesMayHavePrimitive, ConfigurationCommonEventTypeMap optionalConfig, EventTypeRepositoryImpl repo, BeanEventTypeFactory beanEventTypeFactory, EventTypeNameResolver eventTypeNameResolver) throws EventAdapterException { EventTypeMetadata metadata = new EventTypeMetadata(eventTypeName, null, EventTypeTypeClass.APPLICATION, EventTypeApplicationType.MAP, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, false, new EventTypeIdPair(CRC32Util.computeCRC32(eventTypeName), -1)); LinkedHashMap<String, Object> propertyTypes = EventTypeUtility.getPropertyTypesNonPrimitive(propertyTypesMayHavePrimitive); String[] superTypes = null; if (optionalConfig != null && optionalConfig.getSuperTypes() != null && !optionalConfig.getSuperTypes().isEmpty()) { superTypes = optionalConfig.getSuperTypes().toArray(new String[optionalConfig.getSuperTypes().size()]); } MapEventType newEventType = beanEventTypeFactory.getEventTypeFactory().createMap(metadata, propertyTypes, superTypes, optionalConfig != null ? optionalConfig.getStartTimestampPropertyName() : null, optionalConfig != null ? optionalConfig.getEndTimestampPropertyName() : null, beanEventTypeFactory, eventTypeNameResolver); EventType existingType = repo.getTypeByName(eventTypeName); if (existingType != null) { // The existing type must be the same as the type createdStatement if (newEventType.equalsCompareType(existingType) != null) { ExprValidationException message = newEventType.compareEquals(existingType); throw new EPException("Event type named '" + eventTypeName + "' has already been declared with differing column name or type information: " + message.getMessage(), message); } return; } repo.addType(newEventType); }
private static void addXMLDOMType(EventTypeRepositoryImpl repo, String eventTypeName, ConfigurationCommonEventTypeXMLDOM detail, SchemaModel schemaModel, BeanEventTypeFactory beanEventTypeFactory, XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory) { if (detail.getRootElementName() == null) { throw new EventAdapterException("Required root element name has not been supplied"); } EventType existingType = repo.getTypeByName(eventTypeName); if (existingType != null) { String message = "Event type named '" + eventTypeName + "' has already been declared with differing column name or type information"; throw new ConfigurationException(message); } boolean propertyAgnostic = detail.getSchemaResource() == null && detail.getSchemaText() == null; EventTypeMetadata metadata = new EventTypeMetadata(eventTypeName, null, EventTypeTypeClass.STREAM, EventTypeApplicationType.XML, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, propertyAgnostic, new EventTypeIdPair(CRC32Util.computeCRC32(eventTypeName), -1)); EventType type = beanEventTypeFactory.getEventTypeFactory().createXMLType(metadata, detail, schemaModel, null, metadata.getName(), beanEventTypeFactory, xmlFragmentEventTypeFactory, repo); repo.addType(type); if (type instanceof SchemaXMLEventType) { xmlFragmentEventTypeFactory.addRootType((SchemaXMLEventType) type); } } }
public EventSender getEventSender(String eventTypeName) throws EventTypeException { EventType eventType = services.getEventTypeRepositoryBus().getTypeByName(eventTypeName); if (eventType == null) { throw new EventTypeException("Event type named '" + eventTypeName + "' could not be found"); } // handle built-in types ThreadingService threadingService = services.getThreadingService(); if (eventType instanceof BeanEventType) { return new EventSenderBean(this, (BeanEventType) eventType, services.getEventBeanTypedEventFactory(), threadingService); } if (eventType instanceof MapEventType) { return new EventSenderMap(this, (MapEventType) eventType, services.getEventBeanTypedEventFactory(), threadingService); } if (eventType instanceof ObjectArrayEventType) { return new EventSenderObjectArray(this, (ObjectArrayEventType) eventType, services.getEventBeanTypedEventFactory(), threadingService); } if (eventType instanceof BaseXMLEventType) { return new EventSenderXMLDOM(this, (BaseXMLEventType) eventType, services.getEventBeanTypedEventFactory(), threadingService); } if (eventType instanceof AvroSchemaEventType) { return new EventSenderAvro(this, eventType, services.getEventBeanTypedEventFactory(), threadingService); } throw new EventTypeException("An event sender for event type named '" + eventTypeName + "' could not be created as the type is not known"); }
eventType = eventTypeRepositoryPreconfigured.getTypeByName(variableTypeWArray.getClassIdentifier()); if (eventType != null) { type = eventType.getUnderlyingType();
if (services.getEventTypeRepositoryBus().getTypeByName(publicEventType) == null) { throw makePreconditionExceptionPreconfigured(PathRegistryObjectType.EVENTTYPE, publicEventType);