Clone wiki

scm-manager / scheduler-plugin


The scheduler plugin provides an api for other plugins to execute scheduled jobs. The plugin is based on the quartz project.


The plugin needs no further configuration.

API Usage

First you have to add the dependency to your pom.xml e.g.:


But note you should use at least version 1.22 of scm-plugins as parent for your plugin.

Now you can get a SchedulerFactory via injection.

For Example:

public class ReportHandler {

  private final SchedulerFactory schedulerFactory;

  public ReportContextListener(SchedulerFactory schedulerFactory){
    this.schedulerFactory = schedulerFactory;


With the SchedulerFactory SchedulerFactory you can schedule Jobs. To simplify the steps to schedule a job, the scm-scheduler-plugin comes with a helper class called Schedulers.


  • Schedulers must always be executed by an administrator or in an administrative context. Jobs which are executed by a scheduler are executed with administrator privileges.
  • Each job is able to get dependencies via injection.

Further reading

Complete Example

In the following example a ReportJob is executed every minute since the start of scm-manager.

public class ReportContextListener implements ServletContextListener {

  private final AdministrationContext adminContext;
  private final SchedulerFactory schedulerFactory;

  public ReportContextListener(AdministrationContext adminContext,
                               SchedulerFactory schedulerFactory){
    this.adminContext = adminContext;
    this.schedulerFactory = schedulerFactory;

  public void contextDestroyed(ServletContextEvent sce) {}

  public void contextInitialized(ServletContextEvent sce){
    Schedulers.schedule(adminContext, schedulerFactory, 
      SimpleScheduleBuilder.repeatMinutelyForever(), ReportJob.class);

  private static class ReportJob implements Job {

    public void execute(JobExecutionContext context) throws JobExecutionException {
      // do something minutely
      System.out.println(new Date());