Package com.scalagent.scheduler
Class Scheduler
- java.lang.Object
-
- com.scalagent.scheduler.Scheduler
-
- All Implemented Interfaces:
Serializable
public class Scheduler extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classScheduler.WakeUp
-
Field Summary
Fields Modifier and Type Field Description private static booleanDEBUGprivate ScheduleItemitemsevents listprivate static Loggerloggerprivate static longserialVersionUIDdefine serialVersionUID for interoperabilityprivate Timertimerthe timerprivate Scheduler.WakeUpwakeUpCurrent task schedule in Timer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcancel()cancel a wake up task in timer.private voidcheckItems()Checks for ripe events.private voidinsertItem(ScheduleEvent event, ScheduleTask task)insertItemScheduleEventevent.private voidinsertItem(ScheduleItem newItem)Inserts an item in the list ordered by date.private voidreadObject(ObjectInputStream in)private voidremoveItem(ScheduleItem item)Removes an item from the list.voidrestart(Timer timer)restart scheduler.private voidschedule(ScheduleEvent event, long period)schedule wake up task in timer.voidscheduleEvent(ScheduleEvent event, ScheduleTask task)schedule an event.StringtoString()Provides a string image for this object.private voidwriteObject(ObjectOutputStream out)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
logger
private static final Logger logger
-
DEBUG
private static final boolean DEBUG
-
items
private transient ScheduleItem items
events list
-
timer
private transient Timer timer
the timer
-
wakeUp
private transient Scheduler.WakeUp wakeUp
Current task schedule in Timer
-
-
Constructor Detail
-
Scheduler
public Scheduler(Timer timer) throws IOException
Creates the default scheduler.- Parameters:
timer- a ScalAgent timer.- Throws:
IOException
-
-
Method Detail
-
restart
public void restart(Timer timer) throws Exception
restart scheduler.- Parameters:
timer- a ScalAgent timer.- Throws:
Exception
-
toString
public String toString()
Provides a string image for this object.
-
scheduleEvent
public void scheduleEvent(ScheduleEvent event, ScheduleTask task) throws Exception
schedule an event. CallsinsertItem. CallscheckItems.- Parameters:
event- event to schedule.task- task to execute.- Throws:
Exception
-
insertItem
private void insertItem(ScheduleEvent event, ScheduleTask task)
insertItemScheduleEventevent.- Parameters:
event-task- task to execute.
-
insertItem
private void insertItem(ScheduleItem newItem)
Inserts an item in the list ordered by date. Inserts at list head a null dated item.- Parameters:
newItem- item to insert
-
checkItems
private void checkItems() throws ExceptionChecks for ripe events. reschedule event.- Throws:
Exception
-
removeItem
private void removeItem(ScheduleItem item)
Removes an item from the list. Cancel WakeUP if the item is the current.- Parameters:
item- item to remove
-
schedule
private void schedule(ScheduleEvent event, long period)
schedule wake up task in timer.- Parameters:
event- schedule event.period- period in ms.
-
cancel
private void cancel()
cancel a wake up task in timer.
-
writeObject
private void writeObject(ObjectOutputStream out) throws IOException
- Throws:
IOException
-
readObject
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
-