Search in sources :

Example 1 with Trigger

use of org.ballerinalang.siddhi.core.trigger.Trigger in project ballerina by ballerina-lang.

the class DefinitionParserHelper method addEventTrigger.

public static void addEventTrigger(TriggerDefinition triggerDefinition, ConcurrentMap<String, Trigger> eventTriggerMap, ConcurrentMap<String, StreamJunction> streamJunctionMap, SiddhiAppContext siddhiAppContext) {
    if (!eventTriggerMap.containsKey(triggerDefinition.getId())) {
        Trigger trigger;
        if (triggerDefinition.getAtEvery() != null) {
            trigger = new PeriodicTrigger();
        } else if (triggerDefinition.getAt().trim().equalsIgnoreCase(SiddhiConstants.TRIGGER_START)) {
            trigger = new StartTrigger();
        } else {
            trigger = new CronTrigger();
        }
        StreamJunction streamJunction = streamJunctionMap.get(triggerDefinition.getId());
        trigger.init(triggerDefinition, siddhiAppContext, streamJunction);
        siddhiAppContext.addEternalReferencedHolder(trigger);
        eventTriggerMap.putIfAbsent(trigger.getId(), trigger);
    }
}
Also used : CronTrigger(org.ballerinalang.siddhi.core.trigger.CronTrigger) Trigger(org.ballerinalang.siddhi.core.trigger.Trigger) StartTrigger(org.ballerinalang.siddhi.core.trigger.StartTrigger) CronTrigger(org.ballerinalang.siddhi.core.trigger.CronTrigger) PeriodicTrigger(org.ballerinalang.siddhi.core.trigger.PeriodicTrigger) StreamJunction(org.ballerinalang.siddhi.core.stream.StreamJunction) StartTrigger(org.ballerinalang.siddhi.core.trigger.StartTrigger) PeriodicTrigger(org.ballerinalang.siddhi.core.trigger.PeriodicTrigger)

Aggregations

StreamJunction (org.ballerinalang.siddhi.core.stream.StreamJunction)1 CronTrigger (org.ballerinalang.siddhi.core.trigger.CronTrigger)1 PeriodicTrigger (org.ballerinalang.siddhi.core.trigger.PeriodicTrigger)1 StartTrigger (org.ballerinalang.siddhi.core.trigger.StartTrigger)1 Trigger (org.ballerinalang.siddhi.core.trigger.Trigger)1