Last active
December 31, 2015 13:08
-
-
Save os890/7990494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class ProjectStageAwareSchedulerController | |
{ | |
@Inject | |
private Scheduler<Job> jobScheduler; | |
@Inject | |
private ProjectStage projectStage; | |
public void registerJobs() | |
{ | |
if (ProjectStage.Production.equals(this.projectStage)) | |
{ | |
//see 'false' for @Scheduled#onStartup | |
this.jobScheduler.scheduleJob(ManualCdiAwareQuartzJob.class); | |
} | |
} | |
@Scheduled(cronExpression = "0 0/10 * * * ?", onStartup = false) | |
public class ManualCdiAwareQuartzJob implements org.quartz.Job | |
{ | |
@Inject | |
private MyService service; | |
@Override | |
public void execute(JobExecutionContext context) | |
throws JobExecutionException | |
{ | |
//... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment