Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
@Retention(CLASS) @Target({METHOD})
public @interface Scheduled
Runs this method of a bean on a schedule.
Exactly one of cron, fixedRate or fixedDelay (or their String
forms) must be given. The method takes no arguments.
A literal cron expression is parsed by the build, which writes its fields
into the entry point as bit masks and refuses a malformed one: an expression
nobody noticed was wrong otherwise fires never, or every second. One that
reads configuration (${report.cron}) is parsed once at start-up instead.
The format is Spring’s six fields – second, minute, hour, day of month,
month, day of week – plus the @yearly, @monthly, @weekly, @daily
and @hourly macros:
@Scheduled(cron = "0 */15 * * * MON-FRI")
public void refresh() { ... }
Several instances of one server each run every job. lock makes a job run
on one of them at a time, through a row in the database.
Methods
Method details
cron
public abstract String cron() default ""${key} to read one from configuration.zone
public abstract String zone() default ""Europe/Berlin, a fixed offset such as +02:00, or UTC. Empty means
UTC, which is what a server should keep its clock in anyway.fixedRate
public abstract long fixedRate() default -1LfixedDelay
public abstract long fixedDelay() default -1LinitialDelay
public abstract long initialDelay() default -1LfixedRateString
public abstract String fixedRateString() default ""fixedRate as text, which may read configuration.fixedDelayString
public abstract String fixedDelayString() default ""fixedDelay as text, which may read configuration.initialDelayString
public abstract String initialDelayString() default ""initialDelay as text, which may read configuration.thread
public abstract ThreadKind thread() default ThreadKind.PLATFORMexecutor
public abstract String executor() default ""scheduling.lock
public abstract String lock() default ""cn1_scheduler_lock table and is skipped if another instance holds it.
Needs a database.lockAtMostFor
public abstract long lockAtMostFor() default -1L