package cc.smtweb.framework.core.mvc;

import org.springframework.stereotype.Component;

/**
 * 定时器服务
 *
 * @author xkliu
 */
@Component
public class SchedulerManager {
    private ISchedulerWakeup schedulerWakeup;

    public void install(ISchedulerWakeup schedulerWakeup) {
        this.schedulerWakeup = schedulerWakeup;
    }

    /**
     * 唤醒定时器立即执行
     *
     * @param clazz      定时器类
     * @param methodName 有@SwScheduling注解的定时器方法名
     */
    public boolean wakeup(Class<?> clazz, String methodName) {
        if (this.schedulerWakeup != null) {
            return schedulerWakeup.wakeup(clazz, methodName);
        }

        return false;
    }
}
