本文整理汇总了Java中org.wso2.siddhi.query.api.annotation.Annotation.getQueryContextStartIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Annotation.getQueryContextStartIndex方法的具体用法?Java Annotation.getQueryContextStartIndex怎么用?Java Annotation.getQueryContextStartIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.siddhi.query.api.annotation.Annotation
的用法示例。
在下文中一共展示了Annotation.getQueryContextStartIndex方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAnnotation
import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
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;
}
示例2: validateSourceMapperCompatibility
import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
private static void validateSourceMapperCompatibility(StreamDefinition streamDefinition, String sourceType,
String mapType, Source source, SourceMapper sourceMapper,
Annotation sourceAnnotation) {
Class[] inputEventClasses = sourceMapper.getSupportedInputEventClasses();
Class[] outputEventClasses = source.getOutputEventClasses();
//skipping validation for unknown output types
if (outputEventClasses == null || outputEventClasses.length == 0) {
return;
}
boolean matchingSinkAndMapperClasses = false;
for (Class inputEventClass : inputEventClasses) {
for (Class outputEventClass : outputEventClasses) {
if (inputEventClass.isAssignableFrom(outputEventClass)) {
matchingSinkAndMapperClasses = true;
break;
}
}
if (matchingSinkAndMapperClasses) {
break;
}
}
if (!matchingSinkAndMapperClasses) {
throw new SiddhiAppCreationException("At stream '" + streamDefinition.getId() + "', source '" + sourceType
+ "' produces incompatible '" + Arrays.deepToString(outputEventClasses) +
"' classes, while it's source mapper '" + mapType + "' can only consume '" +
Arrays.deepToString(inputEventClasses) + "' classes.",
sourceAnnotation.getQueryContextStartIndex(), sourceAnnotation.getQueryContextEndIndex());
}
}
示例3: validateSinkMapperCompatibility
import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
private static void validateSinkMapperCompatibility(StreamDefinition streamDefinition, String sinkType,
String mapType, Sink sink, SinkMapper sinkMapper,
Annotation sinkAnnotation) {
Class[] inputEventClasses = sink.getSupportedInputEventClasses();
Class[] outputEventClasses = sinkMapper.getOutputEventClasses();
//skipping validation for unknown output types
if (outputEventClasses == null || outputEventClasses.length == 0) {
return;
}
boolean matchingSinkAndMapperClasses = false;
for (Class inputEventClass : inputEventClasses) {
for (Class outputEventClass : outputEventClasses) {
if (inputEventClass.isAssignableFrom(outputEventClass)) {
matchingSinkAndMapperClasses = true;
break;
}
}
if (matchingSinkAndMapperClasses) {
break;
}
}
if (!matchingSinkAndMapperClasses) {
throw new SiddhiAppCreationException("At stream '" + streamDefinition.getId() + "', " +
"sink mapper '" + mapType + "' processes '" + Arrays.deepToString(outputEventClasses) +
"' classes but it's sink '" + sinkType + "' cannot not consume any of those class, where " +
"sink can only consume '" + Arrays.deepToString(inputEventClasses) + "' classes.",
sinkAnnotation.getQueryContextStartIndex(), sinkAnnotation.getQueryContextEndIndex());
}
}
示例4: constructExtension
import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
public static Extension constructExtension(StreamDefinition streamDefinition, String typeName, String typeValue,
Annotation annotation, String defaultNamespace) {
String[] namespaceAndName = typeValue.split(SiddhiConstants.EXTENSION_SEPARATOR);
String namespace;
String name;
if (namespaceAndName.length == 1) {
namespace = defaultNamespace;
name = namespaceAndName[0];
} else if (namespaceAndName.length == 2) {
namespace = namespaceAndName[0];
name = namespaceAndName[1];
} else {
throw new SiddhiAppCreationException("Malformed '" + typeName + "' annotation type '" + typeValue + "' "
+ "provided, for annotation '" + annotation + "' on stream '" + streamDefinition.getId() + "', "
+ "it should be either '<namespace>:<name>' or '<name>'",
annotation.getQueryContextStartIndex(), annotation.getQueryContextEndIndex());
}
return new Extension() {
@Override
public String getNamespace() {
return namespace;
}
@Override
public String getName() {
return name;
}
};
}
示例5: getPayload
import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
private static List<Element> getPayload(Annotation mapAnnotation) {
List<Annotation> attributeAnnotations = mapAnnotation.getAnnotations(SiddhiConstants.ANNOTATION_PAYLOAD);
if (attributeAnnotations.size() == 1) {
List<Element> elements = attributeAnnotations.get(0).getElements();
return elements;
} else if (attributeAnnotations.size() > 1) {
throw new SiddhiAppCreationException("@map() annotation should only contain single @payload() " +
"annotation.", mapAnnotation.getQueryContextStartIndex(), mapAnnotation.getQueryContextEndIndex());
} else {
return null;
}
}
示例6: constructOptionHolder
import org.wso2.siddhi.query.api.annotation.Annotation; //导入方法依赖的package包/类
private static OptionHolder constructOptionHolder(StreamDefinition streamDefinition,
Annotation annotation,
org.wso2.siddhi.annotation.Extension extension,
String[] supportedDynamicOptions) {
List<String> supportedDynamicOptionList = new ArrayList<>();
if (supportedDynamicOptions != null) {
supportedDynamicOptionList = Arrays.asList(supportedDynamicOptions);
}
Map<String, String> options = new HashMap<String, String>();
Map<String, String> dynamicOptions = new HashMap<String, String>();
for (Element element : annotation.getElements()) {
if (Pattern.matches("(.*?)\\{\\{.*?\\}\\}(.*?)", element.getValue())) {
if (supportedDynamicOptionList.contains(element.getKey())) {
dynamicOptions.put(element.getKey(), element.getValue());
} else {
throw new SiddhiAppCreationException("'" + element.getKey() + "' is not a supported " +
"DynamicOption " + "for the Extension '" + extension.namespace() + ":" + extension.name() +
"', it only supports following as its DynamicOptions: " + supportedDynamicOptionList,
annotation.getQueryContextStartIndex(), annotation.getQueryContextEndIndex());
}
} else {
options.put(element.getKey(), element.getValue());
}
}
return new OptionHolder(streamDefinition, options, dynamicOptions, extension);
}
示例7: 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;
}
示例8: 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());
}
}
}
}