Browse Source

Polishing

pull/29732/head
Sam Brannen 2 years ago
parent
commit
0bfddbc9cb
  1. 25
      framework-docs/src/docs/asciidoc/integration/scheduling.adoc
  2. 1
      spring-context/src/main/java/org/springframework/scheduling/Trigger.java
  3. 7
      spring-context/src/main/java/org/springframework/scheduling/TriggerContext.java

25
framework-docs/src/docs/asciidoc/integration/scheduling.adoc

@ -9,7 +9,7 @@ implementations behind the common interfaces abstracts away the differences betw @@ -9,7 +9,7 @@ implementations behind the common interfaces abstracts away the differences betw
SE 5, Java SE 6, and Jakarta EE environments.
Spring also features integration classes to support scheduling with the `Timer`
(part of the JDK since 1.3) and the Quartz Scheduler ( https://www.quartz-scheduler.org/[]).
(part of the JDK since 1.3) and the https://www.quartz-scheduler.org/[Quartz Scheduler].
You can set up both of those schedulers by using a `FactoryBean` with optional references to
`Timer` or `Trigger` instances, respectively. Furthermore, a convenience class for both
the Quartz Scheduler and the `Timer` is available that lets you invoke a method of
@ -171,7 +171,7 @@ much more flexible. @@ -171,7 +171,7 @@ much more flexible.
The `Trigger` interface is essentially inspired by JSR-236 which, as of Spring 3.0,
was not yet officially implemented. The basic idea of the `Trigger` is that execution
times may be determined based on past execution outcomes or even arbitrary conditions.
If these determinations do take into account the outcome of the preceding execution,
If these determinations take into account the outcome of the preceding execution,
that information is available within a `TriggerContext`. The `Trigger` interface itself
is quite simple, as the following listing shows:
@ -208,7 +208,7 @@ Spring provides two implementations of the `Trigger` interface. The most interes @@ -208,7 +208,7 @@ Spring provides two implementations of the `Trigger` interface. The most interes
is the `CronTrigger`. It enables the scheduling of tasks based on
<<scheduling-cron-expression,cron expressions>>.
For example, the following task is scheduled to run 15 minutes past each hour but only
during the 9-to-5 "`business hours`" on weekdays:
during the 9-to-5 "business hours" on weekdays:
[source,java,indent=0]
[subs="verbatim"]
@ -782,9 +782,9 @@ You can use these macros instead of the six-digit value, thus: `@Scheduled(cron @@ -782,9 +782,9 @@ You can use these macros instead of the six-digit value, thus: `@Scheduled(cron
== Using the Quartz Scheduler
Quartz uses `Trigger`, `Job`, and `JobDetail` objects to realize scheduling of all kinds
of jobs. For the basic concepts behind Quartz, see
https://www.quartz-scheduler.org/[]. For convenience purposes, Spring offers a couple of
classes that simplify using Quartz within Spring-based applications.
of jobs. For the basic concepts behind Quartz, see the
https://www.quartz-scheduler.org/[Quartz Web site]. For convenience purposes, Spring
offers a couple of classes that simplify using Quartz within Spring-based applications.
[[scheduling-quartz-jobdetail]]
@ -882,12 +882,13 @@ that merely invoke a method. You need only create the actual business object and @@ -882,12 +882,13 @@ that merely invoke a method. You need only create the actual business object and
wire up the detail object.
By default, Quartz Jobs are stateless, resulting in the possibility of jobs interfering
with each other. If you specify two triggers for the same `JobDetail`, it is
possible that, before the first job has finished, the second one starts. If
`JobDetail` classes implement the `Stateful` interface, this does not happen. The second
job does not start before the first one has finished. To make jobs resulting from the
`MethodInvokingJobDetailFactoryBean` be non-concurrent, set the `concurrent` flag to
`false`, as the following example shows:
with each other. If you specify two triggers for the same `JobDetail`, it is possible
that the second one starts before the first job has finished. If `JobDetail` classes
implement the `Stateful` interface, this does not happen: the second job does not start
before the first one has finished.
To make jobs resulting from the `MethodInvokingJobDetailFactoryBean` be non-concurrent,
set the `concurrent` flag to `false`, as the following example shows:
[source,xml,indent=0,subs="verbatim,quotes"]
----

1
spring-context/src/main/java/org/springframework/scheduling/Trigger.java

@ -34,6 +34,7 @@ public interface Trigger { @@ -34,6 +34,7 @@ public interface Trigger {
/**
* Determine the next execution time according to the given trigger context.
* <p>The default implementation delegates to {@link #nextExecution(TriggerContext)}.
* @param triggerContext context object encapsulating last execution times
* and last completion time
* @return the next execution time as defined by the trigger,

7
spring-context/src/main/java/org/springframework/scheduling/TriggerContext.java

@ -33,9 +33,9 @@ public interface TriggerContext { @@ -33,9 +33,9 @@ public interface TriggerContext {
/**
* Return the clock to use for trigger calculation.
* <p>Defaults to {@link Clock#systemDefaultZone()}.
* @since 5.3
* @see TaskScheduler#getClock()
* @see Clock#systemDefaultZone()
*/
default Clock getClock() {
return Clock.systemDefaultZone();
@ -44,6 +44,7 @@ public interface TriggerContext { @@ -44,6 +44,7 @@ public interface TriggerContext {
/**
* Return the last <i>scheduled</i> execution time of the task,
* or {@code null} if not scheduled before.
* <p>The default implementation delegates to {@link #lastScheduledExecution()}.
* @deprecated as of 6.0, in favor on {@link #lastScheduledExecution()}
*/
@Nullable
@ -64,10 +65,11 @@ public interface TriggerContext { @@ -64,10 +65,11 @@ public interface TriggerContext {
/**
* Return the last <i>actual</i> execution time of the task,
* or {@code null} if not scheduled before.
* <p>The default implementation delegates to {@link #lastActualExecution()}.
* @deprecated as of 6.0, in favor on {@link #lastActualExecution()}
*/
@Deprecated(since = "6.0")
@Nullable
@Deprecated(since = "6.0")
default Date lastActualExecutionTime() {
Instant instant = lastActualExecution();
return instant != null ? Date.from(instant) : null;
@ -83,6 +85,7 @@ public interface TriggerContext { @@ -83,6 +85,7 @@ public interface TriggerContext {
/**
* Return the last completion time of the task,
* or {@code null} if not scheduled before.
* <p>The default implementation delegates to {@link #lastCompletion()}.
* @deprecated as of 6.0, in favor on {@link #lastCompletion()}
*/
@Deprecated(since = "6.0")

Loading…
Cancel
Save