Search code examples
javacronquartz-schedulercronexpressiondeltaspike

Deltaspike and Quartz: How to set cronExpressions from a config file


I guess the title is quite self-explained. I have a job:

import org.apache.deltaspike.scheduler.api.Scheduled;
import org.quartz.Job;

@Scheduled(cronExpression = "0 0/1 * * * ?")
public class JobA implements Job {
  //job code
}

harcoded to run every minute. I would like to set that cron expression from outside, i.e. a config file. I'm using Deltaspike, I can't find a way to achieve it. I was thinking of a class JobDispatcher maybe, from where to create the job and set the cron expression to it, but I see no clue in DeltaSpike documentation

Thanks in advance!


Solution

  • Make the Cron expression a private final static constant deriving its value from a config file and use it in the annotation.