T - The AccessToken typepublic interface TokenProviderJob<T extends AccessToken>
| Modifier and Type | Method and Description |
|---|---|
java.time.Duration |
estimatedRepetitionsDelay()
Provides the real estimated delay between two token renew
repetitions.
|
boolean |
isActive()
Convenience check that returns the active status of this Token Provider
Job.
|
TokenProviderJob<T> |
schedule(double delayModifier)
Schedules the repeated executions by setting their delay as
percentage of the Time-To-Live (TTL) of the Access Token.
|
ScheduledFuture<?> |
start()
Starts a token refresh background job after successfully fetching an
AccessToken from TokenService.
|
void |
stop(boolean graceful)
Stops the asynchronous refreshing job started by this provider (if any)
|
TokenProviderJob<T> schedule(double delayModifier)
#getEstimatedRepetitionsDelayTemporalUnit() (usually
ChronoUnit.SECONDS). The argument must be a double value in the
range (0-1] where 1 stands for 100% of the Access Token TTL.A few notes on fine-tuning the repetitions schedule.
Providing 1 as argument to this method will initiate refresh exactly at the expected moment of expiration. However, calculating this moment cannot be entirely precise because:delayModifier - ScheduledFuture<?> start() throws IOException
IllegalStateException.ScheduledFuture for direct access to the API of the
underlying refresh job scheduler service.IOException - if the attempt to fetch an access token to start the refresh
job failedIllegalStateException - if a job has already been started or if fetching a token did
not throw an IOException but the token was null.void stop(boolean graceful)
graceful - false if hard shutdown is required, true otherwise.boolean isActive()
start() operation can be
used for the same purpose.java.time.Duration estimatedRepetitionsDelay()
#getEstimatedRepetitionsDelayTemporalUnit() method.Copyright © 2017. All rights reserved.