Hi Pranavan,

I assume that you are using Siddhi-2.x branch? If so, how the extension
loading process happens with annotations is as below.

The annotation for Siddhi extension itself is defined in [1]. This is a
standard Java annotation. When the annotation is set, since it has a
retention policy set to runtime for target type, this information will be
available for a particular class that uses this annotation during runtime.
We make use of this to check whether this particular annotation is set
before loading an extension class into Siddhi runtime.
See the code segment below from [2]

                    if
(extension.isAnnotationPresent(SiddhiExtension.class)) {
                        SiddhiExtension siddhiExtension = (SiddhiExtension)
extension.getAnnotation(SiddhiExtension.class);
                        String extensionKey = siddhiExtension.namespace() +
EXTENSION_SEPARATOR + siddhiExtension.function();
                        if (extensionMap.containsKey(extensionKey)) {
                            log.error("Extension class " +
extension.getName() + " not loaded, as there is already an matching
extension " + extensionKey + ", implemented at " +
extensionMap.get(extensionKey).getName());
                        } else {
                            extensionMap.put(extensionKey, extension);
                        }

                    } else {
                        log.error("Extension class " + extension.getName()
+ " not loaded, as it does not have SiddhiExtension Annotation!");
                    }

In the above code segment, we check for the annotation and then only puts
it into a map as an annotation. The annotation is there to simply identify
a class as a Siddhi extension and to extract the namespace and function
from it. This namespace and function is used to derive the key that maps to
an extension reference in Siddhi QL. i.e. we refer to siddhi extensions in
Siddhi QL with <namespace>:<function> format.

Hope you can get an idea from the above explanation. You can browse through
the Siddhi-2.2.x code to get a more detailed idea on how the Siddhi
extension loading process works.

[1]
https://github.com/wso2/siddhi/blob/2.2.x/modules/siddhi-api/src/main/java/org/wso2/siddhi/query/api/extension/annotation/SiddhiExtension.java
[2]
https://github.com/wso2/siddhi/blob/2.2.x/modules/siddhi-core/src/main/java/org/wso2/siddhi/core/extension/holder/AbstractExtensionHolder.java

Thanks,
Lasantha

On 22 June 2015 at 13:28, Nirmal Fernando <[email protected]> wrote:

> Can someone please help Pranavan?
>
> On Sun, Jun 21, 2015 at 3:03 PM, Pranavan Theivendiram <
> [email protected]> wrote:
>
>> Adding Nirmal.
>>
>> *T. Pranavan*
>> *BSc Eng Undergraduate| Department of Computer Science & Engineering
>> ,University of Moratuwa*
>> *Mobile| *0775136836
>>
>> On 21 June 2015 at 14:29, Pranavan Theivendiram <
>> [email protected]> wrote:
>>
>>> Hi Devs,
>>>
>>> I need a brief explanation about how $Subject work?
>>>
>>> The following is an annotation of a custom window processor.
>>>
>>> @SiddhiExtension(namespace = "stratos", function = "secondDerivative")
>>>
>>> I need to know how these annotations work.
>>>
>>> Thanks in advance.
>>>
>>> Thanks
>>> *T. Pranavan*
>>> *BSc Eng Undergraduate| Department of Computer Science & Engineering
>>> ,University of Moratuwa*
>>> *Mobile| *0775136836
>>>
>>
>>
>
>
> --
>
> Thanks & regards,
> Nirmal
>
> Associate Technical Lead - Data Technologies Team, WSO2 Inc.
> Mobile: +94715779733
> Blog: http://nirmalfdo.blogspot.com/
>
>
>


-- 
*Lasantha Fernando*
Senior Software Engineer - Data Technologies Team
WSO2 Inc. http://wso2.com

email: [email protected]
mobile: (+94) 71 5247551
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to