Search in sources :

Example 1 with CronTrigger

use of io.siddhi.core.trigger.CronTrigger in project siddhi by wso2.

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())) {
        AbstractTrigger 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.addTrigger(trigger);
        eventTriggerMap.putIfAbsent(trigger.getId(), trigger);
    }
}
Also used : CronTrigger(io.siddhi.core.trigger.CronTrigger) StreamJunction(io.siddhi.core.stream.StreamJunction) AbstractTrigger(io.siddhi.core.trigger.AbstractTrigger) StartTrigger(io.siddhi.core.trigger.StartTrigger) PeriodicTrigger(io.siddhi.core.trigger.PeriodicTrigger)

Aggregations

StreamJunction (io.siddhi.core.stream.StreamJunction)1 AbstractTrigger (io.siddhi.core.trigger.AbstractTrigger)1 CronTrigger (io.siddhi.core.trigger.CronTrigger)1 PeriodicTrigger (io.siddhi.core.trigger.PeriodicTrigger)1 StartTrigger (io.siddhi.core.trigger.StartTrigger)1