Package org.forgerock.secrets
Class PeriodicallyRefreshedReferenceAsync<T>
java.lang.Object
org.forgerock.secrets.PeriodicallyRefreshedReferenceAsync<T>
- Type Parameters:
T
- The type of the reference.
A simple reference to an object that is periodically refreshed. The refresh is asynchronous, thus the reference is
not guaranteed to be refreshed, neither on time nor at all.
On refresh error, the reference retrieval (get()
will serve the last valid reference until the next
refresh.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Promise<PeriodicallyRefreshedReferenceAsync<T>,
NeverThrowsException> Create an InitializedPeriodicallyRefreshedReferenceAsync
.get()
Gets the reference, refreshing it if necessary.
-
Method Details
-
create
public static <T> Promise<PeriodicallyRefreshedReferenceAsync<T>,NeverThrowsException> create(Supplier<Promise<T, NeverThrowsException>> supplier, Clock clock, Duration refreshDuration) Create an InitializedPeriodicallyRefreshedReferenceAsync
.- Type Parameters:
T
- the type of the reference- Parameters:
supplier
- the supplier to call to refresh the referenceclock
- an instance of a clockrefreshDuration
- the duration between each refresh- Returns:
- an initialized
PeriodicallyRefreshedReferenceAsync
. This promise will fail if the first call to the supplier fails.
-
get
Gets the reference, refreshing it if necessary.- Returns:
- the object.
-