org.apertereports.backbone.scheduler
Class CyclicReportOrderScheduler

java.lang.Object
  extended by org.apertereports.backbone.scheduler.CyclicReportOrderScheduler

public class CyclicReportOrderScheduler
extends Object

A utility class that can schedule cyclic report generation with a configured CronExpression.

The scheduleCyclicReportOrder method simply takes the CyclicReportOrder object and use the cron expression it contains to schedule a CyclicReportOrderJob task.

The scheduler starts immediately after application starts and invokes scanForCyclicReportOrders. The method unschedules all jobs previously scheduled, fetches the cyclic reports form database and schedules them again. This way the previous jobs named after the instance id are removed. The database identifier can vary over time.


Constructor Summary
CyclicReportOrderScheduler()
           
 
Method Summary
static void rescheduleCyclicReportOrder(CyclicReportOrder order)
          Reschedule a given report order.
static void scanForCyclicReportOrders()
          Loads all cyclic reports from database and schedules them in a Quartz scheduler.
static void scheduleCyclicReportOrder(CyclicReportOrder order)
          Schedules a CyclicReportOrderJob for a given cyclic report order.
static void unscheduleCyclicReportOrder(CyclicReportOrder order)
          Unschedules previously scheduled cyclic report order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CyclicReportOrderScheduler

public CyclicReportOrderScheduler()
Method Detail

rescheduleCyclicReportOrder

public static void rescheduleCyclicReportOrder(CyclicReportOrder order)
                                        throws org.quartz.SchedulerException
Reschedule a given report order.

Parameters:
order - A report order
Throws:
org.quartz.SchedulerException - on Quartz error

scheduleCyclicReportOrder

public static void scheduleCyclicReportOrder(CyclicReportOrder order)
                                      throws org.quartz.SchedulerException
Schedules a CyclicReportOrderJob for a given cyclic report order. The CronTrigger is initialized with a cron specification taken from the instance.

Parameters:
order - The instance of cyclic report order
Throws:
org.quartz.SchedulerException - on Quartz error

unscheduleCyclicReportOrder

public static void unscheduleCyclicReportOrder(CyclicReportOrder order)
                                        throws org.quartz.SchedulerException
Unschedules previously scheduled cyclic report order.

Parameters:
order - An instance of cyclic report order to unschedule
Throws:
org.quartz.SchedulerException - on Quartz error

scanForCyclicReportOrders

public static void scanForCyclicReportOrders()
Loads all cyclic reports from database and schedules them in a Quartz scheduler. The method unschedules all jobs queued in the scheduler prior to scheduling. This prevents from a schedule leak when a report order is deleted from database and created again afterwards (the id changes).



Copyright © 2011. All Rights Reserved.