Top Description Inners Constructors Methods
org.springframework.scheduling.support

public Class NoOpTaskScheduler

extends Object
implements TaskScheduler
Class Inheritance
All Implemented Interfaces
org.springframework.scheduling.TaskScheduler
Imports
java.time.Duration, .Instant, java.util.concurrent.CancellationException, .Delayed, .ScheduledFuture, .TimeUnit, org.springframework.lang.Nullable, org.springframework.scheduling.TaskScheduler, .Trigger

A basic, no operation TaskScheduler implementation suitable for disabling scheduling, typically used for test setups.

Will accept any scheduling request but never actually execute it.

Author
Juergen Hoeller
Since
6.1.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ScheduledFuture<?>
schedule(Runnable
the Runnable to execute whenever the trigger fires
task
,
Trigger
an implementation of the Trigger interface, e.g. a org.springframework.scheduling.support.CronTrigger object wrapping a cron expression
trigger
)

Implements org.springframework.scheduling.TaskScheduler.schedule.

Schedule the given Runnable, invoking it whenever the trigger indicates a next execution time.

public ScheduledFuture<?>
schedule(Runnable
the Runnable to execute whenever the trigger fires
task
,
Instant
the desired execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)
startTime
)

Implements org.springframework.scheduling.TaskScheduler.schedule.

Schedule the given Runnable, invoking it at the specified execution time.

public ScheduledFuture<?>
scheduleAtFixedRate(Runnable
the Runnable to execute whenever the trigger fires
task
,
Instant
the desired first execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)
startTime
,
Duration
the interval between successive executions of the task
period
)

Implements org.springframework.scheduling.TaskScheduler.scheduleAtFixedRate.

Schedule the given Runnable, invoking it at the specified execution time and subsequently with the given period.

public ScheduledFuture<?>
scheduleAtFixedRate(Runnable
the Runnable to execute whenever the trigger fires
task
,
Duration
the interval between successive executions of the task
period
)

Implements org.springframework.scheduling.TaskScheduler.scheduleAtFixedRate.

Schedule the given Runnable, starting as soon as possible and invoking it with the given period.

public ScheduledFuture<?>
scheduleWithFixedDelay(Runnable
the Runnable to execute whenever the trigger fires
task
,
Instant
the desired first execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)
startTime
,
Duration
the delay between the completion of one execution and the start of the next
delay
)

Implements org.springframework.scheduling.TaskScheduler.scheduleWithFixedDelay.

Schedule the given Runnable, invoking it at the specified execution time and subsequently with the given delay between the completion of one execution and the start of the next.

public ScheduledFuture<?>
scheduleWithFixedDelay(Runnable
the Runnable to execute whenever the trigger fires
task
,
Duration
the delay between the completion of one execution and the start of the next
delay
)

Implements org.springframework.scheduling.TaskScheduler.scheduleWithFixedDelay.

Schedule the given Runnable, starting as soon as possible and invoking it with the given delay between the completion of one execution and the start of the next.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NoOpTaskSchedulerback to summary
public NoOpTaskScheduler()

Method Detail

scheduleback to summary
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger)

Implements org.springframework.scheduling.TaskScheduler.schedule.

Doc from org.springframework.scheduling.TaskScheduler.schedule.

Schedule the given Runnable, invoking it whenever the trigger indicates a next execution time.

Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

Parameters
task:Runnable

the Runnable to execute whenever the trigger fires

trigger:Trigger

an implementation of the Trigger interface, e.g. a org.springframework.scheduling.support.CronTrigger object wrapping a cron expression

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the task, or null if the given Trigger object never fires (i.e. returns null from Trigger#nextExecution)

Annotations
@Override
@Nullable
scheduleback to summary
public ScheduledFuture<?> schedule(Runnable task, Instant startTime)

Implements org.springframework.scheduling.TaskScheduler.schedule.

Doc from org.springframework.scheduling.TaskScheduler.schedule.

Schedule the given Runnable, invoking it at the specified execution time.

Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

Parameters
task:Runnable

the Runnable to execute whenever the trigger fires

startTime:Instant

the desired execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the task

Annotations
@Override
scheduleAtFixedRateback to summary
public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Instant startTime, Duration period)

Implements org.springframework.scheduling.TaskScheduler.scheduleAtFixedRate.

Doc from org.springframework.scheduling.TaskScheduler.scheduleAtFixedRate.

Schedule the given Runnable, invoking it at the specified execution time and subsequently with the given period.

Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

Parameters
task:Runnable

the Runnable to execute whenever the trigger fires

startTime:Instant

the desired first execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)

period:Duration

the interval between successive executions of the task

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the task

Annotations
@Override
scheduleAtFixedRateback to summary
public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Duration period)

Implements org.springframework.scheduling.TaskScheduler.scheduleAtFixedRate.

Doc from org.springframework.scheduling.TaskScheduler.scheduleAtFixedRate.

Schedule the given Runnable, starting as soon as possible and invoking it with the given period.

Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

Parameters
task:Runnable

the Runnable to execute whenever the trigger fires

period:Duration

the interval between successive executions of the task

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the task

Annotations
@Override
scheduleWithFixedDelayback to summary
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, Instant startTime, Duration delay)

Implements org.springframework.scheduling.TaskScheduler.scheduleWithFixedDelay.

Doc from org.springframework.scheduling.TaskScheduler.scheduleWithFixedDelay.

Schedule the given Runnable, invoking it at the specified execution time and subsequently with the given delay between the completion of one execution and the start of the next.

Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

Parameters
task:Runnable

the Runnable to execute whenever the trigger fires

startTime:Instant

the desired first execution time for the task (if this is in the past, the task will be executed immediately, i.e. as soon as possible)

delay:Duration

the delay between the completion of one execution and the start of the next

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the task

Annotations
@Override
scheduleWithFixedDelayback to summary
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, Duration delay)

Implements org.springframework.scheduling.TaskScheduler.scheduleWithFixedDelay.

Doc from org.springframework.scheduling.TaskScheduler.scheduleWithFixedDelay.

Schedule the given Runnable, starting as soon as possible and invoking it with the given delay between the completion of one execution and the start of the next.

Execution will end once the scheduler shuts down or the returned ScheduledFuture gets cancelled.

Parameters
task:Runnable

the Runnable to execute whenever the trigger fires

delay:Duration

the delay between the completion of one execution and the start of the next

Returns:ScheduledFuture<?>

a ScheduledFuture representing pending completion of the task

Annotations
@Override
org.springframework.scheduling.support back to summary

private Class NoOpTaskScheduler.NoOpScheduledFuture<V>

extends Object
implements ScheduledFuture<V>
Class Inheritance
  • java.lang.Object
  • org.springframework.scheduling.support.NoOpTaskScheduler.NoOpScheduledFuture
All Implemented Interfaces
java.util.concurrent.ScheduledFuture, java.util.concurrent.Future, java.util.concurrent.Delayed, java.lang.Comparable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
cancel(boolean
true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete
mayInterruptIfRunning
)

Implements java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task.

public int
compareTo(Delayed
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public V
get()

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

public V
get(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

public long
getDelay(TimeUnit
the time unit
unit
)

Implements java.util.concurrent.Delayed.getDelay.

Returns the remaining delay associated with this object, in the given time unit.

public boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

public boolean
isDone()

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NoOpScheduledFutureback to summary
private NoOpScheduledFuture()

Method Detail

cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Doc from java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task. This method has no effect if the task is already completed or cancelled, or could not be cancelled for some other reason. Otherwise, if this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task (when known by the implementation) is interrupted in an attempt to stop the task.

The return value from this method does not necessarily indicate whether the task is now cancelled; use isCancelled.

Parameters
mayInterruptIfRunning:boolean

true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete

Returns:boolean

false if the task could not be cancelled, typically because it has already completed; true otherwise. If two or more threads cause a task to be cancelled, then at least one of them returns true. Implementations may provide stronger guarantees.

Annotations
@Override
compareToback to summary
public int compareTo(Delayed other)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
other:Delayed

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
getback to summary
public V get()

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

Returns:V

the computed result

Annotations
@Override
getback to summary
public V get(long timeout, TimeUnit unit)

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:V

the computed result

Annotations
@Override
getDelayback to summary
public long getDelay(TimeUnit unit)

Implements java.util.concurrent.Delayed.getDelay.

Doc from java.util.concurrent.Delayed.getDelay.

Returns the remaining delay associated with this object, in the given time unit.

Parameters
unit:TimeUnit

the time unit

Returns:long

the remaining delay; zero or negative values indicate that the delay has already elapsed

Annotations
@Override
isCancelledback to summary
public boolean isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Returns:boolean

true if this task was cancelled before it completed

Annotations
@Override
isDoneback to summary
public boolean isDone()

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Returns:boolean

true if this task completed

Annotations
@Override