Package org.springframework.scheduling.support

# Class ScheduledMethodRunnable

java.lang.Object
org.springframework.scheduling.support.ScheduledMethodRunnable

All Implemented Interfaces:
  `Runnable`, `SchedulingAwareRunnable`

public class ScheduledMethodRunnable extends Object implements SchedulingAwareRunnable
Variant of `MethodInvokingRunnable` meant to be used for processing of no-arg scheduled methods. Propagates user exceptions to the caller, assuming that an error strategy for Runnables is in place.

Since:
  3.0.6
Author:
  Juergen Hoeller, Brian Clozel
See Also:
  - `ScheduledAnnotationBeanPostProcessor`

## Constructor Summary

Constructors
Constructor
Description
`ScheduledMethodRunnable(Object target, Method method)`
Create a `ScheduledMethodRunnable` for the given target instance, calling the specified method.
`ScheduledMethodRunnable(Object target, Method method, String qualifier, Supplier<io.micrometer.observation.ObservationRegistry> observationRegistrySupplier)`
Create a `ScheduledMethodRunnable` for the given target instance, calling the specified method.
`ScheduledMethodRunnable(Object target, String methodName)`
Create a `ScheduledMethodRunnable` for the given target instance, calling the specified method by name.

## Method Summary

Modifier and Type
Method
Description
`Method`
`getMethod()`
Return the target method to call.
`String`
`getQualifier()`
Return a qualifier associated with this Runnable.
`Object`
`getTarget()`
Return the target instance to call the method on.
`void`
`run()`
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.scheduling.SchedulingAwareRunnable

`isLongLived`

## Constructor Details

### ScheduledMethodRunnable

public ScheduledMethodRunnable(Object target, Method method, @Nullable String qualifier, Supplier<io.micrometer.observation.ObservationRegistry> observationRegistrySupplier)
Create a `ScheduledMethodRunnable` for the given target instance, calling the specified method.

Parameters:
  `target` - the target instance to call the method on
  `method` - the target method to call
  `qualifier` - a qualifier associated with this Runnable, for example, for determining a scheduler to run this scheduled method on
  `observationRegistrySupplier` - a supplier for the observation registry to use
Since:
  6.1

### ScheduledMethodRunnable

public ScheduledMethodRunnable(Object target, Method method)
Create a `ScheduledMethodRunnable` for the given target instance, calling the specified method.

Parameters:
  `target` - the target instance to call the method on
  `method` - the target method to call

### ScheduledMethodRunnable

public ScheduledMethodRunnable(Object target, String methodName) throws NoSuchMethodException
Create a `ScheduledMethodRunnable` for the given target instance, calling the specified method by name.

Parameters:
  `target` - the target instance to call the method on
  `methodName` - the name of the target method
Throws:
  `NoSuchMethodException` - if the specified method does not exist

## Method Details

### getTarget

public Object getTarget()
Return the target instance to call the method on.

### getMethod

public Method getMethod()
Return the target method to call.

### getQualifier

@Nullable public String getQualifier()
Description copied from interface: `SchedulingAwareRunnable`
Return a qualifier associated with this Runnable.

The default implementation returns `null`.

May be used for custom purposes depending on the scheduler implementation. `TaskSchedulerRouter` introspects this qualifier in order to determine the target scheduler to be used for a given Runnable, matching the qualifier value (or the bean name) of a specific `TaskScheduler` or `ScheduledExecutorService` bean definition.

Specified by:
  `getQualifier` in interface `SchedulingAwareRunnable`
See Also:
  - `Scheduled.scheduler()`

### run

public void run()

Specified by:
  `run` in interface `Runnable`

### toString

public String toString()

Overrides:
  `toString` in class `Object`