当前位置: 首页>>代码示例>>Java>>正文


Java Annotation.getElement方法代码示例

本文整理汇总了Java中org.wso2.siddhi.query.api.annotation.Annotation.getElement方法的典型用法代码示例。如果您正苦于以下问题:Java Annotation.getElement方法的具体用法?Java Annotation.getElement怎么用?Java Annotation.getElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.siddhi.query.api.annotation.Annotation的用法示例。


在下文中一共展示了Annotation.getElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: StreamJunction

import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
public StreamJunction(StreamDefinition streamDefinition, ExecutorService executorService, int bufferSize,
                      SiddhiAppContext siddhiAppContext) {
    this.streamDefinition = streamDefinition;
    this.bufferSize = bufferSize;
    this.executorService = executorService;
    this.siddhiAppContext = siddhiAppContext;
    if (siddhiAppContext.getStatisticsManager() != null) {
        this.throughputTracker = QueryParserHelper.createThroughputTracker(siddhiAppContext,
                streamDefinition.getId(),
                SiddhiConstants.METRIC_INFIX_STREAMS, null);
    }
    try {
        Annotation annotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_ASYNC,
                streamDefinition.getAnnotations());
        if (annotation != null) {
            async = true;
            String bufferSizeString = annotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_BUFFER_SIZE);
            if (bufferSizeString != null) {
                this.bufferSize = Integer.parseInt(bufferSizeString);
            }
        }

    } catch (DuplicateAnnotationException e) {
        throw new DuplicateAnnotationException(e.getMessageWithOutContext() + " for the same Stream " +
                streamDefinition.getId(), e, e.getQueryContextStartIndex(), e.getQueryContextEndIndex(),
                siddhiAppContext.getName(), siddhiAppContext.getSiddhiAppString());
    }
    isTraceEnabled = log.isTraceEnabled();
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:30,代码来源:StreamJunction.java

示例2: updateAnnotationRef

import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
private static Annotation updateAnnotationRef(Annotation annotation, String type,
                                              SiddhiAppContext siddhiAppContext) {
    String ref = annotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_REF);
    if (ref != null) {
        Map<String, String> systemConfigs = siddhiAppContext.getSiddhiContext().getConfigManager()
                .extractSystemConfigs(ref);

        if (systemConfigs.size() == 0) {
            throw new SiddhiAppCreationException("The " + type + " element of the name '" + ref +
                    "' is not defined in the configurations file.",
                    annotation.getQueryContextStartIndex(),
                    annotation.getQueryContextEndIndex());
        } else {
            HashMap<String, String> newSystemConfig = new HashMap<>(systemConfigs);

            Map<String, String> collection = annotation.getElements().stream()
                    .collect(Collectors.toMap(Element::getKey, Element::getValue));
            collection.remove(SiddhiConstants.ANNOTATION_ELEMENT_REF);
            newSystemConfig.putAll(collection);

            List<Element> annotationElements = newSystemConfig.entrySet().stream()
                    .map((property) -> new Element(
                            property.getKey(),
                            property.getValue()))
                    .collect(Collectors.toList());

            annotation.setElements(annotationElements);
        }
    }
    return annotation;
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:32,代码来源:DefinitionParserHelper.java

示例3: addTable

import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
public static void addTable(TableDefinition tableDefinition, ConcurrentMap<String, Table> tableMap,
                            SiddhiAppContext siddhiAppContext) {

    if (!tableMap.containsKey(tableDefinition.getId())) {

        MetaStreamEvent tableMetaStreamEvent = new MetaStreamEvent();
        tableMetaStreamEvent.addInputDefinition(tableDefinition);
        for (Attribute attribute : tableDefinition.getAttributeList()) {
            tableMetaStreamEvent.addOutputData(attribute);
        }

        StreamEventPool tableStreamEventPool = new StreamEventPool(tableMetaStreamEvent, 10);
        StreamEventCloner tableStreamEventCloner = new StreamEventCloner(tableMetaStreamEvent,
                tableStreamEventPool);

        Annotation annotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_STORE,
                tableDefinition.getAnnotations());

        Table table;
        ConfigReader configReader = null;
        RecordTableHandlerManager recordTableHandlerManager = null;
        RecordTableHandler recordTableHandler = null;
        if (annotation != null) {
            annotation = updateAnnotationRef(annotation, SiddhiConstants.NAMESPACE_STORE, siddhiAppContext);
            String tableType = annotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
            Extension extension = new Extension() {
                @Override
                public String getNamespace() {
                    return SiddhiConstants.NAMESPACE_STORE;
                }

                @Override
                public String getName() {
                    return tableType;
                }
            };
            recordTableHandlerManager = siddhiAppContext.getSiddhiContext().getRecordTableHandlerManager();
            if (recordTableHandlerManager != null) {
                recordTableHandler = recordTableHandlerManager.generateRecordTableHandler();
            }
            table = (Table) SiddhiClassLoader.loadExtensionImplementation(extension,
                    TableExtensionHolder.getInstance(siddhiAppContext));
            configReader = siddhiAppContext.getSiddhiContext().getConfigManager()
                    .generateConfigReader(extension.getNamespace(), extension.getName());
        } else {
            table = new InMemoryTable();
        }
        table.initTable(tableDefinition, tableStreamEventPool, tableStreamEventCloner, configReader,
                siddhiAppContext, recordTableHandler);
        if (recordTableHandler != null) {
            recordTableHandlerManager.registerRecordTableHandler(recordTableHandler.getElementId(),
                    recordTableHandler);
        }
        tableMap.putIfAbsent(tableDefinition.getId(), table);
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:57,代码来源:DefinitionParserHelper.java

示例4: addEventSource

import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
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())) {
            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);
            final String mapType = mapAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
            if (sourceType != null && mapType != null) {
                SourceHandlerManager sourceHandlerManager = siddhiAppContext.getSiddhiContext().
                        getSourceHandlerManager();
                SourceHandler sourceHandler = null;
                if (sourceHandlerManager != null) {
                    sourceHandler = sourceHandlerManager.generateSourceHandler();
                }
                // 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);

                OptionHolder sourceOptionHolder = constructOptionHolder(streamDefinition, sourceAnnotation,
                        source.getClass().getAnnotation(org.wso2.siddhi.annotation.Extension.class), null);
                OptionHolder mapOptionHolder = constructOptionHolder(streamDefinition, mapAnnotation,
                        sourceMapper.getClass().getAnnotation(org.wso2.siddhi.annotation.Extension.class), null);

                AttributesHolder attributesHolder = getAttributeMappings(mapAnnotation, mapType, streamDefinition);
                String[] transportPropertyNames = getTransportPropertyNames(attributesHolder);
                try {
                    source.init(sourceType, sourceOptionHolder, sourceMapper, transportPropertyNames,
                            configReader, mapType, mapOptionHolder, attributesHolder.payloadMappings,
                            attributesHolder.transportMappings, mapperConfigReader, sourceHandler, streamDefinition,
                            siddhiAppContext);
                } catch (Throwable t) {
                    ExceptionUtil.populateQueryContext(t, sourceAnnotation, siddhiAppContext);
                    throw t;
                }
                siddhiAppContext.getSnapshotService().addSnapshotable(source.getStreamDefinition().getId(), source);
                if (sourceHandlerManager != null) {
                    sourceHandlerManager.registerSourceHandler(sourceHandler.getElementId(), sourceHandler);
                    siddhiAppContext.getSnapshotService().addSnapshotable(streamDefinition.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);
                }
            } else {
                throw new SiddhiAppCreationException("Both @Sink(type=) and @map(type=) are required.",
                        sourceAnnotation.getQueryContextStartIndex(), sourceAnnotation.getQueryContextEndIndex());
            }
        }
    }
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:77,代码来源:DefinitionParserHelper.java


注:本文中的org.wso2.siddhi.query.api.annotation.Annotation.getElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。