public static void addEventSource(StreamDefinition streamDefinition,
                                      ConcurrentMap<String, List<Source>> eventSourceMap,
                                      SiddhiAppContext siddhiAppContext) {
        for (Annotation sourceAnnotation : streamDefinition.getAnnotations()) {
            if (SiddhiConstants.ANNOTATION_SOURCE.equalsIgnoreCase(sourceAnnotation.getName())) {
                try {
                    sourceAnnotation = updateAnnotationRef(sourceAnnotation, SiddhiConstants.NAMESPACE_SOURCE,
                            siddhiAppContext);
                    Annotation mapAnnotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_MAP,
                            sourceAnnotation.getAnnotations());
                    if (mapAnnotation == null) {
                        mapAnnotation = Annotation.annotation(SiddhiConstants.ANNOTATION_MAP).element(SiddhiConstants
                                .ANNOTATION_ELEMENT_TYPE, "passThrough");
                    }
                    final String sourceType = sourceAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
                    if (sourceType == null) {
                        throw new SiddhiAppCreationException(
                                "Attribute 'type' does not exist for annotation '" + sourceAnnotation + "'",
                                sourceAnnotation, siddhiAppContext);
                    }
                    final String mapType = mapAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
                    if (mapType == null) {
                        throw new SiddhiAppCreationException(
                                "Attribute 'type' does not exist for annotation '" + mapAnnotation + "'",
                                mapAnnotation, siddhiAppContext);
                    }

                    SourceHandlerManager sourceHandlerManager = siddhiAppContext.getSiddhiContext().
                            getSourceHandlerManager();
                    SourceHandler sourceHandler = null;
                    if (sourceHandlerManager != null) {
                        sourceHandler = sourceHandlerManager.generateSourceHandler(sourceType);
                    }
                    // load input transport extension
                    Extension sourceExtension = constructExtension(streamDefinition, SiddhiConstants.ANNOTATION_SOURCE,
                            sourceType, sourceAnnotation, SiddhiConstants.NAMESPACE_SOURCE);
                    Source source = (Source) SiddhiClassLoader.loadExtensionImplementation(sourceExtension,
                            SourceExecutorExtensionHolder.getInstance(siddhiAppContext));
                    ConfigReader configReader = siddhiAppContext.getSiddhiContext().getConfigManager()
                            .generateConfigReader(sourceExtension.getNamespace(), sourceExtension.getName());

                    // load input mapper extension
                    Extension mapperExtension = constructExtension(streamDefinition, SiddhiConstants.ANNOTATION_MAP,
                            mapType, sourceAnnotation, SiddhiConstants.NAMESPACE_SOURCE_MAPPER);
                    SourceMapper sourceMapper = (SourceMapper) SiddhiClassLoader.loadExtensionImplementation(
                            mapperExtension, SourceMapperExecutorExtensionHolder.getInstance(siddhiAppContext));
                    ConfigReader mapperConfigReader = siddhiAppContext.getSiddhiContext().getConfigManager()
                            .generateConfigReader(mapperExtension.getNamespace(), mapperExtension.getName());
                    validateSourceMapperCompatibility(streamDefinition, sourceType, mapType, source, sourceMapper,
                            sourceAnnotation);

                    io.siddhi.annotation.Extension sourceExt =
                            source.getClass().getAnnotation(io.siddhi.annotation.Extension.class);
                    OptionHolder sourceOptionHolder = constructOptionHolder(streamDefinition, sourceAnnotation,
                            sourceExt, null, true);
                    Map<String, String> deploymentProperties = createDeploymentProperties(sourceAnnotation, sourceExt);
                    OptionHolder mapOptionHolder = constructOptionHolder(streamDefinition, mapAnnotation,
                            sourceMapper.getClass().getAnnotation(io.siddhi.annotation.Extension.class),
                            null, false);

                    AttributesHolder attributesHolder = getAttributeMappings(mapAnnotation, mapType, streamDefinition);
                    String[] transportPropertyNames = getTransportPropertyNames(attributesHolder);
                    source.init(sourceType, sourceOptionHolder, sourceMapper, transportPropertyNames,
                            configReader, mapType, mapOptionHolder, attributesHolder.payloadMappings,
                            attributesHolder.transportMappings, mapperConfigReader, sourceHandler, streamDefinition,
                            deploymentProperties, siddhiAppContext);
                    if (sourceHandlerManager != null) {
                        sourceHandlerManager.registerSourceHandler(sourceHandler.getId(), sourceHandler);
                    }
                    List<Source> eventSources = eventSourceMap.get(streamDefinition.getId());
                    if (eventSources == null) {
                        eventSources = new ArrayList<>();
                        eventSources.add(source);
                        eventSourceMap.put(streamDefinition.getId(), eventSources);
                    } else {
                        eventSources.add(source);
                    }
                } catch (Throwable t) {
                    ExceptionUtil.populateQueryContext(t, sourceAnnotation, siddhiAppContext);
                    throw t;
                }
            }
        }
    }
Utility class for queryParser to help with QueryRuntime
generation.
modules/siddhi-core/src/main/java/io/siddhi/core/util/parser/helper/DefinitionParserHelper.java