Package org.axonframework.common
Class ClockUtils
java.lang.Object
org.axonframework.common.ClockUtils
Global access point for the framework's current
Clock.
This utility provides a shared clock abstraction that can be read from anywhere in the framework and overridden in
tests or integration scenarios. It also implements InstantSource so callers can use it wherever an instant
source is required.
- Since:
- 5.2.0
- Author:
- Jan Galinski
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Clockget()Returns the currently configured global clock.static Instantinstant()Adapts the current clock to theInstantSourceinterface.static Clockreset()Restores the global clock to the default UTC clock.static ClockReplaces the currently configured global clock.
-
Field Details
-
SUPPLIER
A supplier that returns the current instant of the global clock.
-
-
Method Details
-
get
Returns the currently configured global clock.- Returns:
- the shared clock instance, or the default UTC clock if none has been configured explicitly
-
set
Replaces the currently configured global clock.- Parameters:
clock- the new global clock to use- Returns:
- the clock that was installed
-
reset
Restores the global clock to the default UTC clock.- Returns:
- the default UTC clock
-
instant
Adapts the current clock to theInstantSourceinterface.- Returns:
- the
InstantSource.instant()of the current clock
-