kz.greetgo.scheduling.Scheduled Maven / Gradle / Ivy
Show all versions of greetgo.scheduling Show documentation
package kz.greetgo.scheduling;
import java.lang.annotation.*;
/**
* Marks a method that will be executed on the schedule, and also defines this schedule.
* The method should be public.
*
*
* There are two schedule format: calendar and periodic
*
* CALENDAR FORMAT OF THE SCHEDULE
*
* Schedule format: <hours>:<minutes> (<days of the month>)
* {<days of the week>} [<Months>]
*
*
* Some examples:
*
*
*
*
* Example
* When a task will be initiated
*
*
*
*
* 12:30 {monday,wednesday} [March-June,December]
* at 12:30 from Monday to Wednesday from March to June and on December from Monday to Wednesday as well
*
*
* 08-18:00/15 {mon-fri}
* every 15 minutes from 8 a.m. till 6 p.m. on weekdays
*
*
* *:0 {mon}
* every one hour in 00 minutes all day and night, but only on Mondays
*
*
* 00:10 (3,7,10)
* at 01:10 at night, on the third, seventh and tenth day of each month
*
*
*
*
* A detailed description of the schedule format:
*
*
* Months are in two languages: Russian and English. First three letters of the month can also be used.
* Any register can be used.
*
*
* Days of the week are in two languages: Russian and English. First three letters can be used as well.
* Any register can be used. First two letters can also be used: MO, TU, WE, TH, FR, SA, SU.
*
*
*
*
* Schedule element
* Possible forms
* Description and examples
*
*
*
*
* <minutes> or <hours> or <months>
* DATE
* Sets a specific minute or an hour, when it is time to start the task
*
*
* DATE1-DATE1
* Defines several values in the range:
DATE1 <= x <= DATE2
*
*
* DATE1/DATE2
* defines several values starting with DATE1 with a period DATE2:
* x = DATE1
x = DATE1 + DATE2
x = DATE1 + 2*DATE2
x = DATE1 + 3*DATE2
......
*
*
*
*
* PERIODIC FORMAT OF THE SCHEDULE
*
* Schedule format in Russian: [параллельно] повторять каждые NN1 сек|мин [, начиная с паузы NN2 сек|мин]
*
*
* Schedule format in English: [parallel] repeat every NN1 sec|min [, after pause in NN2 sec|min]
*
*
* where [ ] - means optionality, | - means possibility "one of"
*
If the parameter NN2 is not specified, the value NN2 = 0 is applied
*
After the start of the scheduler, the system waits for time NN2 and initiates the task. And then, depending on the presence of the word
* "параллель|parallel", which defines the parallel mode of startup (the word is present) or sequential mode
* of startup (the word is not present):
*
In parallel mode the system without waiting for completion of the task, awaiting time NN1 and initiates the task again,
* and then also without waiting for completion of the task, awaiting time NN1 initiates the task again, and then till the stop of the scheduler
* the task will be initiated at regular intervals of NN1.
*
In sequential mode the system waits for task completion, and then starts timing.
* When the time NN1 is over, the task is initiated again. Then waiting for task completion again, after completion -
* waiting for time NN1 and startup. And then till the stop of the scheduler.
*
*
* Examples:
*
repeat every 13 min after pause in 17 sec
*
*
parallel repeat every 13 sec after pause in 17 min
*
*
repeat every 13 min
*
*
parallel repeat every 13 min
*
*
повторять каждые 13 мин, начиная с паузы 17 сек
*
*
параллельно повторять каждые 13 мин, начиная с паузы 17 сек
*
*
повторять каждые 13 сек
*
*
параллельно повторять каждые 13 сек
*
*/
@Documented
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Scheduled {
String value();
}