CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-wso2-siddhi--siddhi-annotations

Annotation support for the Siddhi Complex Event Processing Engine, providing extension definitions and validation for stream processors, functions, aggregations, and other extension types.

Overview
Eval results
Files

utility-classes.mddocs/

Utility Classes

Supporting classes that provide data type definitions, validation exceptions, and constants used throughout the Siddhi annotation framework. These utilities enable proper type validation, error handling, and extension classification.

Capabilities

DataType Enum

Standardized data type definitions used in @Parameter and @ReturnAttribute annotations to specify supported data types for extension parameters and return values.

/**
 * Enum types used in @Parameter and @ReturnAttribute annotations.
 * Provides standardized data type definitions for Siddhi extensions.
 */
public enum DataType {
    /** String data type for text values */
    STRING,
    
    /** Integer data type for 32-bit signed integers */
    INT,
    
    /** Long data type for 64-bit signed integers */
    LONG,
    
    /** Float data type for 32-bit floating point numbers */
    FLOAT,
    
    /** Double data type for 64-bit floating point numbers */
    DOUBLE,
    
    /** Boolean data type for true/false values */
    BOOL,
    
    /** Object data type for arbitrary Java objects */
    OBJECT,
    
    /** Time data type for temporal values */
    TIME
}

Usage Examples:

// Single data type
@Parameter(name = "count", type = {DataType.INT})

// Multiple allowed data types
@Parameter(name = "value", type = {DataType.INT, DataType.LONG, DataType.DOUBLE})

// Return attribute with specific type
@ReturnAttribute(type = {DataType.STRING}, description = "Processed result")

// Flexible numeric parameter
@Parameter(name = "threshold", 
          type = {DataType.FLOAT, DataType.DOUBLE}, 
          description = "Threshold value for comparison")

AnnotationValidationException

Custom exception class for annotation validation errors, providing structured error reporting during compile-time validation.

/**
 * Custom exception for annotation validation errors.
 * Thrown by AbstractAnnotationProcessor during compile-time validation.
 * 
 * Extends java.lang.Exception
 */
public class AnnotationValidationException extends Exception {
    
    /**
     * Constructs a new exception with the specified detail message.
     * 
     * @param message - Detail message explaining the validation error
     */
    public AnnotationValidationException(String message);
    
    /**
     * Constructs a new exception with the specified detail message and cause.
     * 
     * @param message - Detail message explaining the validation error
     * @param throwable - Underlying cause of the validation error
     */
    public AnnotationValidationException(String message, Throwable throwable);
    
    /**
     * Constructs a new exception with the specified cause.
     * 
     * @param throwable - Underlying cause of the validation error
     */
    public AnnotationValidationException(Throwable throwable);
}

Usage Example:

public void validateParameter(Parameter param) throws AnnotationValidationException {
    if (param.name().isEmpty()) {
        throw new AnnotationValidationException(
            "Parameter name cannot be empty in extension: " + extensionClass
        );
    }
    
    if (param.type().length == 0) {
        throw new AnnotationValidationException(
            "Parameter type array cannot be empty for: " + param.name()
        );
    }
}

AnnotationConstants

Constants class containing superclass names and namespace definitions used for extension classification and validation.

/**
 * Siddhi annotation constants class.
 * Contains superclass names and namespace constants for extension validation.
 */
public class AnnotationConstants {
    
    // Extension Superclass Constants
    /** Superclass name for SinkMapper extensions */
    public static final String SINK_MAPPER_SUPER_CLASS = 
        "org.wso2.siddhi.core.stream.output.sink.SinkMapper";
    
    /** Superclass name for Sink extensions */
    public static final String SINK_SUPER_CLASS = 
        "org.wso2.siddhi.core.stream.output.sink.Sink";
    
    /** Superclass name for Script extensions */
    public static final String SCRIPT_SUPER_CLASS = 
        "org.wso2.siddhi.core.function.Script";
    
    /** Superclass name for FunctionExecutor extensions */
    public static final String FUNCTION_EXECUTOR_SUPER_CLASS = 
        "org.wso2.siddhi.core.executor.function.FunctionExecutor";
    
    /** Superclass name for AggregationAttribute extensions */
    public static final String AGGREGATION_ATTRIBUTE_SUPER_CLASS = 
        "org.wso2.siddhi.core.query.selector.attribute.aggregator.AttributeAggregator";
    
    /** Superclass name for DistributionStrategy extensions */
    public static final String DISTRIBUTION_STRATEGY_SUPER_CLASS = 
        "org.wso2.siddhi.core.stream.output.sink.distributed.DistributionStrategy";
    
    /** Superclass name for StreamProcessor extensions */
    public static final String STREAM_PROCESSOR_SUPER_CLASS = 
        "org.wso2.siddhi.core.query.processor.stream.StreamProcessor";
    
    /** Superclass name for StreamFunctionProcessor extensions */
    public static final String STREAM_FUNCTION_PROCESSOR_SUPER_CLASS = 
        "org.wso2.siddhi.core.query.processor.stream.function.StreamFunctionProcessor";
    
    /** Superclass name for Store extensions */
    public static final String STORE_SUPER_CLASS = 
        "org.wso2.siddhi.core.table.record.AbstractRecordTable";
    
    /** Superclass name for Source extensions */
    public static final String SOURCE_SUPER_CLASS = 
        "org.wso2.siddhi.core.stream.input.source.Source";
    
    /** Superclass name for SourceMapper extensions */
    public static final String SOURCE_MAPPER_SUPER_CLASS = 
        "org.wso2.siddhi.core.stream.input.source.SourceMapper";
    
    /** Superclass name for WindowProcessor extensions */
    public static final String WINDOW_PROCESSOR_CLASS = 
        "org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor";
    
    /** Superclass name for IncrementalAttributeAggregator extensions */
    public static final String INCREMENTAL_ATTRIBUTE_AGGREGATOR_SUPER_CLASS = 
        "org.wso2.siddhi.core.query.selector.attribute.aggregator.incremental.IncrementalAttributeAggregator";
    
    // Namespace Constants
    /** Default namespace for DistributionStrategy extensions */
    public static final String DISTRIBUTION_STRATEGY_NAMESPACE = "distributionStrategy";
    
    /** Default namespace for Store extensions */
    public static final String STORE_NAMESPACE = "store";
    
    /** Default namespace for Source extensions */
    public static final String SOURCE_NAMESPACE = "source";
    
    /** Default namespace for SourceMapper extensions */
    public static final String SOURCE_MAPPER_NAMESPACE = "sourceMapper";
    
    /** Default namespace for Sink extensions */
    public static final String SINK_NAMESPACE = "sink";
    
    /** Default namespace for SinkMapper extensions */
    public static final String SINK_MAPPER_NAMESPACE = "sinkMapper";
}

Usage Examples:

// Extension superclass validation
String superClass = getMatchingSuperClass(element, new String[]{
    AnnotationConstants.FUNCTION_EXECUTOR_SUPER_CLASS,
    AnnotationConstants.STREAM_PROCESSOR_SUPER_CLASS,
    AnnotationConstants.SINK_SUPER_CLASS
});

// Namespace determination
if (superClass.equals(AnnotationConstants.SINK_SUPER_CLASS)) {
    expectedNamespace = AnnotationConstants.SINK_NAMESPACE;
}

// Processor selection
switch (superClass) {
    case AnnotationConstants.FUNCTION_EXECUTOR_SUPER_CLASS:
        processor = new FunctionExecutorValidationAnnotationProcessor(className);
        break;
    case AnnotationConstants.STREAM_PROCESSOR_SUPER_CLASS:
        processor = new StreamProcessorValidationAnnotationProcessor(className);
        break;
}

Integration with External Libraries

ClassIndex Integration

The annotations framework integrates with ClassIndex for runtime discovery of annotated extensions:

// @Extension is marked with @IndexAnnotated
@IndexAnnotated
public @interface Extension {
    // Extension definition
}

// ClassIndex allows runtime discovery
Iterable<Class<?>> extensions = ClassIndex.getAnnotated(Extension.class);

Usage in Extension Loading:

import org.atteo.classindex.ClassIndex;

// Discover all extension classes at runtime
for (Class<?> extensionClass : ClassIndex.getAnnotated(Extension.class)) {
    Extension annotation = extensionClass.getAnnotation(Extension.class);
    
    // Register extension with Siddhi engine
    registerExtension(
        annotation.namespace(),
        annotation.name(),
        extensionClass
    );
}

Error Handling Patterns

Validation Error Messages

The utility classes provide structured error messages following consistent patterns:

// Parameter validation error
throw new AnnotationValidationException(MessageFormat.format(
    "The @Extension -> @Parameter -> name:{0} -> description annotated in class {1} is null or empty.",
    parameterName, extensionClassFullName
));

// Return attribute validation error  
throw new AnnotationValidationException(MessageFormat.format(
    "The @Extension -> @ReturnAttribute -> name {0} annotated in class {1} is not in camelCase format.",
    returnAttributeName, extensionClassFullName
));

// Basic validation error
throw new AnnotationValidationException(MessageFormat.format(
    "The @Extension -> namespace annotated in class {0} is null or empty.",
    extensionClassFullName
));

Exception Handling During Validation

try {
    abstractAnnotationProcessor.basicParameterValidation(name, description, namespace);
    abstractAnnotationProcessor.parameterValidation(parameters);
    abstractAnnotationProcessor.returnAttributesValidation(returnAttributes);
    abstractAnnotationProcessor.systemParametersValidation(systemParameters);
    abstractAnnotationProcessor.examplesValidation(examples);
} catch (AnnotationValidationException e) {
    // Convert to compilation error
    messager.printMessage(Diagnostic.Kind.ERROR, e.getMessage(), element);
}

This utility framework ensures consistent type definitions, error handling, and extension classification throughout the Siddhi annotations system.

Install with Tessl CLI

npx tessl i tessl/maven-org-wso2-siddhi--siddhi-annotations

docs

annotation-processors.md

core-annotations.md

index.md

utility-classes.md

tile.json