这个Quartz Cron Expression是如何执行的?

时间:2009-07-16 08:22:03

标签: cron quartz-scheduler scheduling

我有以下内容;

private String cronExpression = "";
private final String jobID = "MyJObID";
...
Scheduler scheduler = ServiceLocator.getInstance().getScheduler();
CronTrigger trigger = new CronTrigger(jobID , Scheduler.DEFAULT_GROUP, cronExpression);
JobDetail jobDetail = new JobDetail(jobID , Scheduler.DEFAULT_GROUP, MyJob.class);
scheduler.scheduleJob(jobDetail, trigger);

我的问题是这个作业是什么时候触发空的cron表达式?

2 个答案:

答案 0 :(得分:1)

你确定它有效吗?

只需查看org.quartz.CronExpression#buildExpression()方法代码,就会抛出异常:

        if (exprOn <= DAY_OF_WEEK) {
            throw new ParseException("Unexpected end of expression.",
                        expression.length());
        }

      // exprOn should be equal to SECOND in case of empty String given

[在Quartz 1.6.0中检查]

答案 1 :(得分:0)

感谢帮助人员,找到了问题。

经过一夜的搜索后,我发现该类已在JBoss中注册为MBean,并且cron表达式属性的值在部署描述符中设置为某个有意义的值