Commits

Sebastian Sdorra committed e5ea974

improve javadoc

  • Participants
  • Parent commits da84edc

Comments (0)

Files changed (1)

src/main/java/sonia/scm/scheduler/api/Schedulers.java

 import sonia.scm.web.security.PrivilegedAction;
 
 /**
- * Util class for SCM-Manager quartz schedulers.
+ * Util class for SCM-Manager quartz 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.
+ * To execute a scheduler, the {@link SchedulerFactory} is needed, 
+ * which is available via injection.
+ * <p>&nbsp;</p>
+ * <b>Sample Job:</b>
+ * <pre><code> public class ReportJob implements Job
+ * {
+ *   {@literal @}Inject
+ *   public ReportJob(ReportContext context){
+ *     this.context = context;
+ *   }
+ *
+ *   {@literal @}Override
+ *   public void execute(JobExecutionContext context) throws JobExecutionException {
+ *     this.context.sendReports();
+ *   }
+ *
+ * }</code></pre>
  * <p>&nbsp;</p>
  * <b>Execute an Scheduler on startup of SCM-Manager:</b>
- * <pre><code>
- * @Extension
+ * <pre><code> {@literal @}Extension
  * public class ReportContextListener implements ServletContextListener {
  *
  *   private final AdministrationContext adminContext;
  *   private final SchedulerFactory schedulerFactory;
  *
- *   @Inject
+ *   {@literal @}Inject
  *   public ReportContextListener(AdministrationContext adminContext,
  *     SchedulerFactory schedulerFactory){
  *     this.adminContext = adminContext;
  *     this.schedulerFactory = schedulerFactory;
  *   }
  *
- *   @Override
+ *   {@literal @}Override
  *   public void contextDestroyed(ServletContextEvent sce) {}
  *
- *   @Override
+ *   {@literal @}Override
  *   public void contextInitialized(ServletContextEvent sce){
  *     Schedulers.schedule(adminContext, schedulerFactory,
  *       SimpleScheduleBuilder.repeatMinutelyForever(), ReportJob.class);
  *   }
- * }
- * </code></pre>
+ * }</code></pre>
  *
  * @author Sebastian Sdorra
  */