All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jooby.quartz.Scheduled Maven / Gradle / Ivy

There is a newer version: 3.5.3
Show newest version
/*
 * Jooby https://jooby.io
 * Apache License Version 2.0 https://jooby.io/LICENSE.txt
 * Copyright 2014 Edgar Espina
 */
package io.jooby.quartz;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.quartz.Trigger;

/**
 * Define a {@link Trigger Quartz Trigger}. Using one of three expressions:
 *
 * 
    *
  • interval: like5s;delay=60s;repeat=*, delay and repeat * are optional *
  • cron: like 0/3 * * * * ? *
  • property name: a property defined in .conf file which has one of two previous * formats *
* * Examples: * *

Run every 5 minutes, start immediately and repeat for ever: * *

 * @Scheduled("5m")
 *
 * @Scheduled("5m; delay=0")
 *
 * @Scheduled("5m; delay=0; repeat=*")
 * 
* * Previous, expressions are identical. * *

Run every 1 hour with an initial delay of 15 minutes for 10 times * *

 * @Scheduled("1h; delay=15m; repeat=10")
 * 
* *

Fire at 12pm (noon) every day * *

 * 0 0 12 * * ?
 * 
* *

Fire at 10:15am every day * *

 * 0 15 10 ? * *
 * 
* * @author edgar * @since 0.5.0 */ @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Scheduled { /** * Expression can be one of these three options: * *
    *
  1. Interval: 10s, 10secs, 10minutes, 1h, etc... *
  2. Cron expression: 0/3 * * * * ? *
  3. Reference to a property, where the property value is one of the two previous options *
* * @return an expression to create an scheduler. * @see com.typesafe.config.Config#getDuration(String, java.util.concurrent.TimeUnit) */ String value(); /** * Sometimes, when you have many Triggers (or few worker threads in your Quartz thread pool), * Quartz may not have enough resources to immediately fire all of the Triggers that are scheduled * to fire at the same time. In this case, you may want to control which of your Triggers get * first crack at the available Quartz worker threads. For this purpose, you can set the priority * property on a Trigger. * * @return Quartz calendar. */ String calendar() default ""; /** * Quartz Calendar objects (not java.util.Calendar objects) can be associated with triggers at the * time the trigger is defined and stored in the scheduler. Calendars are useful for excluding * blocks of time from the the trigger’s firing schedule. * * @return Priority default 5. */ int priority() default Trigger.DEFAULT_PRIORITY; /** * A misfire occurs if a persistent trigger "misses" its firing time because of the scheduler * being shutdown, or because there are no available threads in Quartz’s thread pool for executing * the job. * * @return Misfire instruction. */ int misfire() default Trigger.MISFIRE_INSTRUCTION_SMART_POLICY; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy