Skip to content

Instantly share code, notes, and snippets.

@sdorra
Last active December 10, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdorra/4444488 to your computer and use it in GitHub Desktop.
Save sdorra/4444488 to your computer and use it in GitHub Desktop.
@Extension
public class ReportContextListener implements ServletContextListener {
private final AdministrationContext adminContext;
private final SchedulerFactory schedulerFactory;
@Inject
public ReportContextListener(AdministrationContext adminContext,
SchedulerFactory schedulerFactory){
this.adminContext = adminContext;
this.schedulerFactory = schedulerFactory;
}
@Override
public void contextDestroyed(ServletContextEvent sce) {}
@Override
public void contextInitialized(ServletContextEvent sce){
Schedulers.schedule(adminContext, schedulerFactory,
SimpleScheduleBuilder.repeatMinutelyForever(), ReportJob.class);
}
private static class ReportJob implements Job {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
// do something minutely
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment