public static void validateEventBeanClassVisibility(Class clazz) { if (!Modifier.isPublic(clazz.getModifiers())) { throw new EventAdapterException("Event class '" + clazz.getName() + "' does not have public visibility"); } }
log.debug("Exception provided by event adapter: " + ex.getMessage(), ex); throw new ExprValidationException(ex.getMessage(), ex);
EventType type = eventTypeNameResolver.getTypeByName(superName); if (type == null) { throw new EventAdapterException("Supertype by name '" + superName + "' could not be found"); throw new EventAdapterException("Supertype by name '" + superName + "' is not a Map, expected a Map event type as a supertype"); throw new EventAdapterException("Supertype by name '" + superName + "' is not an Object-array type, expected a Object-array event type as a supertype"); throw new EventAdapterException("Supertype by name '" + superName + "' is not an Avro type, expected a Avro event type as a supertype");
public void validateExistingType(EventType existingType, AvroSchemaEventType proposedType) { if (!(existingType instanceof AvroSchemaEventType)) { throw new EventAdapterException("Type by name '" + proposedType.getName() + "' is not a compatible type " + "(target type underlying is '" + existingType.getUnderlyingType().getName() + "', " + "source type underlying is '" + proposedType.getUnderlyingType().getName() + "')"); } Schema proposed = (Schema) proposedType.getSchema(); Schema existing = (Schema) ((AvroSchemaEventType) existingType).getSchema(); if (!proposed.equals(existing)) { throw new EventAdapterException("Event type named '" + existingType.getName() + "' has already been declared with differing column name or type information\n" + "schemaExisting: " + AvroSchemaUtil.toSchemaStringSafe(existing) + "\n" + "schemaProposed: " + AvroSchemaUtil.toSchemaStringSafe(proposed)); } }
public static EventBeanSPI getShellForType(EventType eventType) { if (eventType instanceof BeanEventType) { return new BeanEventBean(null, eventType); } if (eventType instanceof ObjectArrayEventType) { return new ObjectArrayEventBean(null, eventType); } if (eventType instanceof MapEventType) { return new MapEventBean(null, eventType); } if (eventType instanceof BaseXMLEventType) { return new XMLEventBean(null, eventType); } throw new EventAdapterException("Event type '" + eventType.getName() + "' is not an runtime-native event type"); }
public static EventBeanAdapterFactory getAdapterFactoryForType(EventType eventType, EventBeanTypedEventFactory eventBeanTypedEventFactory, EventTypeAvroHandler eventTypeAvroHandler) { if (eventType instanceof BeanEventType) { return new EventBeanAdapterFactoryBean(eventType, eventBeanTypedEventFactory); } if (eventType instanceof ObjectArrayEventType) { return new EventBeanAdapterFactoryObjectArray(eventType, eventBeanTypedEventFactory); } if (eventType instanceof MapEventType) { return new EventBeanAdapterFactoryMap(eventType, eventBeanTypedEventFactory); } if (eventType instanceof BaseXMLEventType) { return new EventBeanAdapterFactoryXml(eventType, eventBeanTypedEventFactory); } if (eventType instanceof AvroSchemaEventType) { return new EventBeanAdapterFactoryAvro(eventType, eventTypeAvroHandler); } throw new EventAdapterException("Event type '" + eventType.getName() + "' is not an runtime-native event type"); }
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 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); } } }