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

public Class ScheduledMethodRunnable

extends Object
implements SchedulingAwareRunnable
Class Inheritance
All Implemented Interfaces
org.springframework.scheduling.SchedulingAwareRunnable, java.lang.Runnable
Imports
java.lang.reflect.InvocationTargetException, .Method, .UndeclaredThrowableException, java.util.function.Supplier, io.micrometer.observation.Observation, .ObservationRegistry, org.springframework.lang.Nullable, org.springframework.scheduling.SchedulingAwareRunnable, org.springframework.util.ReflectionUtils

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.
Authors
Juergen Hoeller, Brian Clozel
Since
3.0.6
See Also
org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor

Field Summary

Modifier and TypeField and Description
private static final ScheduledTaskObservationConvention
private final Method
private final Supplier<ObservationRegistry>
private final String
private final Object

Constructor Summary

AccessConstructor and Description
public
ScheduledMethodRunnable(Object
the target instance to call the method on
target
,
Method
the target method to call
method
,
String
a qualifier associated with this Runnable, e.g. for determining a scheduler to run this scheduled method on
qualifier
,
Supplier<ObservationRegistry>
a supplier for the observation registry to use
observationRegistrySupplier
)

Create a ScheduledMethodRunnable for the given target instance, calling the specified method.

public
ScheduledMethodRunnable(Object
the target instance to call the method on
target
,
Method
the target method to call
method
)

Create a ScheduledMethodRunnable for the given target instance, calling the specified method.

public
ScheduledMethodRunnable(Object
the target instance to call the method on
target
,
String
the name of the target method
methodName
)

Create a ScheduledMethodRunnable for the given target instance, calling the specified method by name.

Method Summary

Modifier and TypeMethod and Description
public Method
getMethod()

Return the target method to call.

public String
getQualifier()

Overrides default org.springframework.scheduling.SchedulingAwareRunnable.getQualifier.

Return a qualifier associated with this Runnable.

public Object
getTarget()

Return the target instance to call the method on.

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

private void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_CONVENTIONback to summary
private static final ScheduledTaskObservationConvention DEFAULT_CONVENTION
methodback to summary
private final Method method
observationRegistrySupplierback to summary
private final Supplier<ObservationRegistry> observationRegistrySupplier
qualifierback to summary
private final String qualifier
Annotations
@Nullable
targetback to summary
private final Object target

Constructor Detail

ScheduledMethodRunnableback to summary
public ScheduledMethodRunnable(Object target, Method method, String qualifier, Supplier<ObservationRegistry> observationRegistrySupplier)

Create a ScheduledMethodRunnable for the given target instance, calling the specified method.

Parameters
target:Object

the target instance to call the method on

method:Method

the target method to call

qualifier:String

a qualifier associated with this Runnable, e.g. for determining a scheduler to run this scheduled method on

observationRegistrySupplier:Supplier<ObservationRegistry>

a supplier for the observation registry to use

Since
6.1
ScheduledMethodRunnableback to summary
public ScheduledMethodRunnable(Object target, Method method)

Create a ScheduledMethodRunnable for the given target instance, calling the specified method.

Parameters
target:Object

the target instance to call the method on

method:Method

the target method to call

ScheduledMethodRunnableback to summary
public ScheduledMethodRunnable(Object target, String methodName) throws NoSuchMethodException

Create a ScheduledMethodRunnable for the given target instance, calling the specified method by name.

Parameters
target:Object

the target instance to call the method on

methodName:String

the name of the target method

Exceptions
NoSuchMethodException:
if the specified method does not exist

Method Detail

getMethodback to summary
public Method getMethod()

Return the target method to call.

getQualifierback to summary
public String getQualifier()

Overrides default org.springframework.scheduling.SchedulingAwareRunnable.getQualifier.

Doc from org.springframework.scheduling.SchedulingAwareRunnable.getQualifier.

Return a qualifier associated with this Runnable.

The default implementation returns null.

May be used for custom purposes depending on the scheduler implementation. org.springframework.scheduling.config.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 org.springframework.scheduling.TaskScheduler or java.util.concurrent.ScheduledExecutorService bean definition.

Annotations
@Override
@Nullable
getTargetback to summary
public Object getTarget()

Return the target instance to call the method on.

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
runInternalback to summary
private void runInternal(ScheduledTaskObservationContext context)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override