- java.lang.Object
-
- aeonics.entity.Entity
-
- aeonics.manager.Manager.Type
-
- aeonics.manager.Scheduler
-
- All Implemented Interfaces:
Exportable
,Snapshotable
public abstract class Scheduler extends Manager.Type
Manages execution of scheduled tasks. The scheduler will inspect theRegistry
for allScheduler.Cron
and will run them accordingly.It is not expected that the scheduler have a precision smaller than 1 second.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Scheduler.Cron
A task that should be executed at regular interval.
-
Constructor Summary
Constructors Constructor Description Scheduler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
at(java.util.function.Consumer<java.time.ZonedDateTime> task, java.time.ZonedDateTime time)
Schedules a task to run once at the specified time.Scheduler.Cron.Type
every(java.util.function.Consumer<java.time.ZonedDateTime> task, long step, java.time.temporal.ChronoUnit unit)
Schedules a task to run at a specified time interval.Scheduler.Cron.Type
every(java.util.function.Consumer<java.time.ZonedDateTime> task, long step, java.time.temporal.ChronoUnit unit, java.time.ZonedDateTime from)
Schedules a task to run at a specified time interval starting a the specified moment.void
in(java.util.function.Consumer<java.time.ZonedDateTime> task, long delay)
Schedules a task to run once after the specified delay has elapsed.java.lang.Class<? extends Manager.Type>
manager()
Hardcoded manager typeabstract void
refresh()
This method will re-inspect allScheduler.Cron
in theRegistry
to determine if some tasks need to run.-
Methods inherited from class aeonics.manager.Manager.Type
category, internal
-
Methods inherited from class aeonics.entity.Entity
addRelation, addRelation, addRelation, cast, clearRelation, config, defineRelation, equals, export, firstRelation, hashCode, hasRelation, id, name, name, onCreate, onRemove, onUpdate, parameter, relations, relationships, removeRelation, snapshot, type, valueOf, valueOf
-
-
-
-
Method Detail
-
manager
public final java.lang.Class<? extends Manager.Type> manager()
Hardcoded manager type- Specified by:
manager
in classManager.Type
- Returns:
- the type of manager
-
at
public abstract void at(java.util.function.Consumer<java.time.ZonedDateTime> task, java.time.ZonedDateTime time)
Schedules a task to run once at the specified time. If the time is past due, the task runs immediately.- Parameters:
task
- the task to run, it will receive the current time when calledtime
- the time at which the task should run
-
in
public void in(java.util.function.Consumer<java.time.ZonedDateTime> task, long delay)
Schedules a task to run once after the specified delay has elapsed.- Parameters:
task
- the task to run, it will receive the current time when calleddelay
- the number of milliseconds of delay from the time of calling this method
-
every
public Scheduler.Cron.Type every(java.util.function.Consumer<java.time.ZonedDateTime> task, long step, java.time.temporal.ChronoUnit unit)
Schedules a task to run at a specified time interval.- Parameters:
task
- the task to run, it will receive the current time when calledstep
- the time intervalunit
- the time unit- Returns:
- the cron task
-
every
public Scheduler.Cron.Type every(java.util.function.Consumer<java.time.ZonedDateTime> task, long step, java.time.temporal.ChronoUnit unit, java.time.ZonedDateTime from)
Schedules a task to run at a specified time interval starting a the specified moment.- Parameters:
task
- the task to run, it will receive the current time when calledstep
- the time intervalunit
- the time unitfrom
- the starting point in time- Returns:
- the cron task
-
refresh
public abstract void refresh()
This method will re-inspect allScheduler.Cron
in theRegistry
to determine if some tasks need to run. You should call this method every time a Cron task is added in the Registry so that the scheduler recomputes the next action date.
-
-