Expando createTrigger()

in src/main/groovy/grails/plugins/quartz/config/TriggersConfigBuilder.groovy [63:95]


    Expando createTrigger(name, Map attributes) {
        def triggerClass

        def triggerAttributes = attributes ? new HashMap(attributes) : [:]

        prepareCommonTriggerAttributes(triggerAttributes)

        String triggerType = normalizeTriggerType(name)

        switch (triggerType) {
            case 'simple':
                triggerClass = SimpleTriggerImpl
                prepareSimpleTriggerAttributes(triggerAttributes)
                break
            case 'cron':
                triggerClass = CronTriggerImpl
                prepareCronTriggerAttributes(triggerAttributes)
                break
            case 'custom':
                if (!triggerAttributes?.triggerClass) {
                    throw new Exception("Custom trigger must have 'triggerClass' attribute")
                }
                triggerClass = (Class) triggerAttributes.remove('triggerClass')
                if (!Trigger.isAssignableFrom(triggerClass)){
                    throw new Exception("Custom trigger class must implement org.quartz.Trigger class.")
                }
                break
            default:
                throw new Exception("Invalid format")
        }

        new Expando(clazz: CustomTriggerFactoryBean, triggerClass: triggerClass, triggerAttributes: triggerAttributes)
    }