Class ScheduleService
java.lang.Object
org.chenile.scheduler.db.ScheduleService
- All Implemented Interfaces:
SmartInitializingSingleton
Saves, reads and deletes the caller tenant's schedules, and keeps
ChenileScheduler in
step: a change is scheduled after its transaction commits. At startup every stored schedule is
scheduled, and the scheduler is told to read definitions from the database when they fire, so
that a schedule saved on one node fires correctly on another.
With a database per tenant the stored schedules are loaded tenant by tenant (TenantSupplier, TenantScope); without tenants (one database, or no
multi-datasource-utils) they are loaded once.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SchedulerDefinitionRepositoryprivate final ChenileSchedulerprivate final TenantScopeprivate final TenantSupplier -
Constructor Summary
ConstructorsConstructorDescriptionScheduleService(SchedulerDefinitionRepository repository, ChenileScheduler scheduler, TenantSupplier tenantSupplier, TenantScope tenantScope) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidafterCommit(Runnable change) voidvoidfindAll()private voidprivate voidloadStoredSchedules(Set<String> loaded) Schedules the current database's rows; an id already defined in JSON or code fails startup.private NotFoundExceptionsave(SchedulerDefinitionEntity schedule) private Stringtenant()private SchedulerDefinitionprivate voidvalidate(SchedulerDefinitionEntity schedule) Name is the database's own rule; everything else is the scheduler's.
-
Field Details
-
repository
-
scheduler
-
tenantSupplier
-
tenantScope
-
-
Constructor Details
-
ScheduleService
public ScheduleService(SchedulerDefinitionRepository repository, ChenileScheduler scheduler, TenantSupplier tenantSupplier, TenantScope tenantScope)
-
-
Method Details
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiatedin interfaceSmartInitializingSingleton
-
loadStoredSchedules
-
save
-
retrieve
-
findAll
-
delete
-
validate
Name is the database's own rule; everything else is the scheduler's. -
toDefinition
-
tenant
-
notFound
-
invalid
-
afterCommit
-
CHENILE