本文整理了Java中org.wso2.siddhi.query.api.annotation.Annotation
类的一些代码示例,展示了Annotation
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation
类的具体详情如下:
包路径:org.wso2.siddhi.query.api.annotation.Annotation
类名称:Annotation
[英]Annotation for siddhi functions and extensions
[中]siddhi函数和扩展的注释
代码示例来源:origin: wso2/siddhi
public static Annotation getAnnotation(String annotationName, List<Annotation> annotationList) {
Annotation annotation = null;
for (Annotation aAnnotation : annotationList) {
if (annotationName.equalsIgnoreCase(aAnnotation.getName())) {
if (annotation == null) {
annotation = aAnnotation;
} else {
throw new DuplicateAnnotationException("Annotation @" + annotationName + " is defined twice",
aAnnotation.getQueryContextStartIndex(), aAnnotation.getQueryContextEndIndex());
}
}
}
return annotation;
}
代码示例来源:origin: wso2/siddhi
public static Annotation annotation(String name) {
return new Annotation(name);
}
代码示例来源:origin: wso2/siddhi
public SiddhiApp(String name) {
annotations.add(Annotation.annotation("info").element("name", name));
}
代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core
/**
* Traverse annotations and returns the name
*
* @param annotations
* @return
*/
private static String getName(List<Annotation> annotations) {
String name = UUID.randomUUID().toString();
if (annotations != null) {
for (Annotation annotation : annotations) {
if (annotation.getName().equals(EventProcessorConstants.NAME)) {
name = annotation.getElements().get(0).getValue();
}
}
}
return name;
}
代码示例来源:origin: org.wso2.siddhi/siddhi-extension-event-table
String dataSourceName = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_DATASOURCE_NAME);
String tableName = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_TABLE_NAME);
DataSource dataSource = executionPlanContext.getSiddhiContext().getSiddhiDataSource(dataSourceName);
List<Attribute> attributeList = tableDefinition.getAttributeList();
String jdbcConnectionUrl = fromAnnotation.getElement(RDBMSEventTableConstants.EVENT_TABLE_RDBMS_TABLE_JDBC_URL);
String username = fromAnnotation.getElement(RDBMSEventTableConstants.EVENT_TABLE_RDBMS_TABLE_USERNAME);
String password = fromAnnotation.getElement(RDBMSEventTableConstants.EVENT_TABLE_RDBMS_TABLE_PASSWORD);
String driverName = fromAnnotation.getElement(RDBMSEventTableConstants.EVENT_TABLE_RDBMS_TABLE_DRIVER_NAME);
List<Element> connectionPropertyElements = null;
connectionPropertyElements = connectionAnnotation.getElements();
String cacheType = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_CACHE);
cacheSizeInString = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_CACHE_SIZE);
String cacheLoadingType = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_CACHE_LOADING);
String cacheValidityInterval = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_CACHE_VALIDITY_PERIOD);
String bloomsEnabled = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_BLOOM_FILTERS);
String bloomFilterValidityInterval = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_BLOOM_VALIDITY_PERIOD);
String bloomsFilterSize = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_BLOOM_FILTERS_SIZE);
String bloomsFilterHash = fromAnnotation.getElement(RDBMSEventTableConstants.ANNOTATION_ELEMENT_BLOOM_FILTERS_HASH);
if (bloomsFilterSize != null) {
bloomFilterSize = Integer.parseInt(bloomsFilterSize);
代码示例来源:origin: org.wso2.extension.siddhi.io.file/siddhi-io-file
protected void init(StreamDefinition streamDefinition, OptionHolder optionHolder,
ConfigReader configReader, SiddhiAppContext siddhiAppContext) {
this.siddhiAppContext = siddhiAppContext;
uriOption = optionHolder.validateAndGetOption(Constants.FILE_URI);
String append = optionHolder.validateAndGetStaticValue(Constants.APPEND, Constants.TRUE);
properties = new HashMap<>();
properties.put(Constants.ACTION, Constants.WRITE);
if (Constants.TRUE.equalsIgnoreCase(append)) {
properties.put(Constants.APPEND, append);
}
String mapType = streamDefinition.getAnnotations().get(0).getAnnotations().get(0).getElements().get(0)
.getValue();
addEventSeparator = optionHolder.isOptionExists(Constants.ADD_EVENT_SEPARATOR) ?
Boolean.parseBoolean(optionHolder.validateAndGetStaticValue(Constants.ADD_EVENT_SEPARATOR)) :
!mapType.equalsIgnoreCase("csv");
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
/**
* Generates AnnotationConfig String for the given Siddhi Annotation
* @param annotation Siddhi Annotation
* @return String representing the Annotation
*/
public String generateAnnotationConfig(Annotation annotation) {
StringBuilder annotationConfig = new StringBuilder();
annotationConfig.append("@");
annotationConfig.append(annotation.getName());
annotationConfig.append("(");
List<String> annotationMembers = new ArrayList<>();
for (Element element : annotation.getElements()) {
annotationMembers.add(element.toString());
}
for (Annotation innerAnnotation : annotation.getAnnotations()) {
annotationMembers.add(generateAnnotationConfig(innerAnnotation));
}
annotationConfig.append(String.join(", ", annotationMembers));
annotationConfig.append(")");
preserveCodeSegment(annotation);
return annotationConfig.toString();
}
代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core
/**
* Traverse the annotation and returns the execute group id
*
* @param annotations
* @return
*/
private static String getExecuteGroup(List<Annotation> annotations) {
String id = null;
if (annotations != null) {
for (Annotation annotation : annotations) {
if (annotation.getName().equals(EventProcessorConstants.DIST)) {
if (annotation.getElement(EventProcessorConstants.EXEC_GROUP) != null) {
id = annotation.getElement(EventProcessorConstants.EXEC_GROUP);
}
}
}
}
return id;
}
代码示例来源:origin: wso2/siddhi
if (annotation != null) {
Element element = null;
for (Element aElement : annotation.getElements()) {
if (elementName == null) {
if (aElement.getKey() == null) {
代码示例来源:origin: wso2/siddhi
public List<Annotation> getAnnotations(String name) {
List<Annotation> results = new ArrayList<>();
for (Annotation annotation : annotations) {
if (annotation.getName().equalsIgnoreCase(name)) {
results.add(annotation);
}
}
return results;
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.sp.jobmanager.core
/**
* Provide the parallelism count for pass-through query. In case of multiple user given values,
* lowest one will be selected. Default parallelism value would be 1.
*
* @param annotation Source annotation
* @return Parallelism count for pass-through query
*/
private int getSourceParallelism(Annotation annotation) {
Set<Integer> parallelismSet = new HashSet<>();
List<Annotation> distAnnotations = annotation.getAnnotations(
SiddhiTopologyCreatorConstants.DISTRIBUTED_IDENTIFIER);
if (distAnnotations.size() > 0) {
for (Annotation distAnnotation : distAnnotations) {
if (distAnnotation.getElement(SiddhiTopologyCreatorConstants.PARALLEL_IDENTIFIER) != null) {
parallelismSet.add(Integer.valueOf(distAnnotation.getElement(
SiddhiTopologyCreatorConstants.PARALLEL_IDENTIFIER)));
} else {
return SiddhiTopologyCreatorConstants.DEFAULT_PARALLEL;
}
}
} else {
return SiddhiTopologyCreatorConstants.DEFAULT_PARALLEL;
}
return parallelismSet.stream().min(Comparator.comparing(Integer::intValue)).get();
}
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.eventtable
tableDefinition.getAnnotations());
this.tableDefinition = tableDefinition;
this.tableName = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_TABLE_NAME);
if (this.tableName == null) {
throw new IllegalArgumentException("The property " + AnalyticsEventTableConstants.ANNOTATION_TABLE_NAME +
" must be provided for analytics event tables.");
this.primaryKeys = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_PRIMARY_KEYS);
this.indices = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_INDICES);
String mergeSchemaProp = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_MERGE_SCHEMA);
if (mergeSchemaProp != null) {
mergeSchemaProp = mergeSchemaProp.trim();
String waitForIndexingProp = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_WAIT_FOR_INDEXING);
if (waitForIndexingProp != null) {
waitForIndexingProp = waitForIndexingProp.trim();
String maxSearchResultCountProp = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_MAX_SEARCH_RESULT_COUNT);
if (maxSearchResultCountProp != null) {
maxSearchResultCountProp = maxSearchResultCountProp.trim();
String cachingProp = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_CACHING);
if (cachingProp != null) {
this.caching = Boolean.parseBoolean(cachingProp.trim());
String cacheTimeoutSecsProp = fromAnnotation.getElement(AnalyticsEventTableConstants.ANNOTATION_CACHE_TIMEOUT_SECONDS);
if (cacheTimeoutSecsProp != null) {
this.cacheTimeoutSeconds = Integer.parseInt(cacheTimeoutSecsProp.trim());
代码示例来源:origin: org.wso2.siddhi/siddhi-query-compiler
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Annotation visitApp_annotation(@NotNull SiddhiQLParser.App_annotationContext ctx) {
Annotation annotation = new Annotation((String) visit(ctx.name()));
for (SiddhiQLParser.Annotation_elementContext elementContext : ctx.annotation_element()) {
annotation.element((Element) visit(elementContext));
}
populateQueryContext(annotation, ctx);
return annotation;
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
/**
* Generates MapperPayloadOrAttribute object, with the given Siddhi Annotation
* @param attributesOrPayloadAnnotation Siddhi Annotation, denoting @attribute or @payload
* @return MapperPayloadOrAttribute object
*/
private MapperPayloadOrAttribute generateMapperPayloadOrAttributes(Annotation attributesOrPayloadAnnotation) {
List<PayloadOrAttributeElement> elements = new ArrayList<>();
for (Element element : attributesOrPayloadAnnotation.getElements()) {
elements.add(generatePayloadOrAttributesElement(element));
}
MapperPayloadOrAttributeType mapperPayloadOrAttributesType = getMapperAttributeOrPayloadType(elements);
if (mapperPayloadOrAttributesType == MapperPayloadOrAttributeType.MAP) {
return generateMapperMapAttribute(attributesOrPayloadAnnotation.getName(), elements);
}
return generateMapperListAttribute(attributesOrPayloadAnnotation.getName(), elements);
}
代码示例来源:origin: org.wso2.extension.siddhi.store.rdbms/siddhi-store-rdbms
List<Element> primaryKeyList = (primaryKeys == null) ? new ArrayList<>() : primaryKeys.getElements();
List<Element> indexElementList = (indices == null) ? new ArrayList<>() : indices.getElements();
List<String> queries = new ArrayList<>();
Map<String, String> fieldLengths = RDBMSTableUtils.processFieldLengths(storeAnnotation.getElement(
ANNOTATION_ELEMENT_FIELD_LENGTHS));
this.validateFieldLengths(fieldLengths);
代码示例来源:origin: org.wso2.extension.siddhi.io.http/siddhi-io-http
/**
* The initialization method for {@link Sink}, which will be called before other methods and validate
* the all configuration and getting the intial values.
*
* @param outputStreamDefinition containing stream definition bind to the {@link Sink}
* @param optionHolder Option holder containing static and dynamic configuration related
* to the {@link Sink}
* @param configReader to read the sink related system configuration.
* @param siddhiAppContext the context of the {@link org.wso2.siddhi.query.api.SiddhiApp} used to
* get siddhi related utilty functions.
*/
@Override
protected void init(StreamDefinition outputStreamDefinition, OptionHolder optionHolder,
ConfigReader configReader, SiddhiAppContext siddhiAppContext) {
//read configurations
this.messageIdOption = optionHolder.validateAndGetOption(HttpConstants.MESSAGE_ID);
this.sourceId = optionHolder.validateAndGetStaticValue(HttpConstants.SOURCE_ID);
this.httpHeaderOption = optionHolder.getOrCreateOption(HttpConstants.HEADERS, HttpConstants.DEFAULT_HEADER);
this.mapType = outputStreamDefinition.getAnnotations().get(0).getAnnotations().get(0).getElements().get(0)
.getValue();
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core
String correlationId = null;
List<String> options = new ArrayList<>();
for (Element element : sourceOrSinkAndConnectedElement.getKey().getElements()) {
if (element.getKey().equalsIgnoreCase(TYPE)) {
type = element.getValue();
for (Annotation sourceOrSinkAnnotation : sourceOrSinkAndConnectedElement.getKey().getAnnotations()) {
if (MAP.equalsIgnoreCase(sourceOrSinkAnnotation.getName())) {
map = generateMapperConfig(sourceOrSinkAnnotation);
} else {
代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core
/**
* Traverse the annotation and returns the parallelism hint
*
* @param annotations
* @return
*/
private static int getParallelism(List<Annotation> annotations, String elementKey) {
int parallelism = 1;
if (annotations != null) {
for (Annotation annotation : annotations) {
if (annotation.getName().equals(EventProcessorConstants.DIST)) {
if (annotation.getElement(elementKey) != null) {
parallelism = Integer.parseInt(annotation.getElement(elementKey));
if (parallelism == 0) {
parallelism = 1;
}
return parallelism;
}
}
}
}
return parallelism;
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core
/**
* Obtain query name of each siddhi app elements
*/
private void loadQueryName(List<Annotation> queryAnnotations, SiddhiAppElements siddhiAppElements) {
for (Annotation annotation : queryAnnotations) {
for (Element element : annotation.getElements()) {
siddhiAppElements.setQueryName(element.getValue());
}
}
if (siddhiAppElements.getQueryName() == null) {
siddhiAppElements.setQueryName(Constants.DEFAULT_QUERY_NAME);
}
}
代码示例来源:origin: org.wso2.siddhi/siddhi-query-api
public List<Annotation> getAnnotations(String name) {
List<Annotation> results = new ArrayList<>();
for (Annotation annotation : annotations) {
if (annotation.getName().equalsIgnoreCase(name)) {
results.add(annotation);
}
}
return results;
}
内容来源于网络,如有侵权,请联系作者删除!