-
Notifications
You must be signed in to change notification settings - Fork 16
Esper : Creating Custom Annotations
You can follow below steps to create custom annotations which can be used in EPL statements.
-
Define an annotation class
-
Create a Metadata class to hold information after compiling your EPL annotation.
-
Create a Processor class which implements com.ebay.jetstream.event.processor.esper.annotation.processor.AnnotationProcessor
Annotation processor class should parse the corresponding annotation attributes and create a Metadata object and inject it into StatementAnnotationInfo Object with Annotation class as the key.
public StatementAnnotationInfo process(String statement, EngineMetadata engineMetadata, Map<String, AnnotationConfiguration> annotConfigMap, StatementAnnotationInfo stmtAnntInfo, Collection<EventSink> registeredSinkList);
-
Create a Listener class which implements com.ebay.jetstream.event.processor.esper.annotation.listener.AnnotationListener
AnnotationListener class holds processed event from EsperEventListener and Metadata.
```java
public JetstreamEvent processMetaInformation(JetstreamEvent event,
StatementAnnotationInfo annotationInfo);
```
StatementAnnotationInfo holds annotation metadata. Using this metadata object , information can be injected/retrieved into/from the event.
-
Configuring Annotation to Esper Engine.
Set below property to EsperConfiguration bean to register your annotation with Esper Engine.
Sample configuration
<property name="annotationConfig">
<list>
<bean class="com.ebay.jetstream.event.processor.esper.annotation.config.AnnotationConfiguration">
<property name="annotation" value="OutputTo" />
<property name="className" value="com.ebay.jetstream.event.processor.esper.annotation.OutputTo" />
<property name="processor">
<bean class="com.ebay.jetstream.event.processor.esper.annotation.processor.OutputToAnnotationProcessor" />
</property>
<property name="listener">
<bean class="com.ebay.jetstream.event.processor.esper.annotation.listener.OutputToAnnotationListener" />
</property>
</bean>
</property>