3939 * by each entity/connection is performed. This callback typically propagates
4040 * the new credentials in the entity state, e.g. sending the new password to the
4141 * broker for AMQP connections.
42+ * <p>
43+ * Instances are preferably created with {@link DefaultCredentialsRefreshServiceBuilder}.
4244 */
4345public class DefaultCredentialsRefreshService implements CredentialsRefreshService {
4446
@@ -89,6 +91,13 @@ public class DefaultCredentialsRefreshService implements CredentialsRefreshServi
8991 */
9092 private final Function <Duration , Boolean > approachingExpirationStrategy ;
9193
94+ /**
95+ * Constructor. Consider using {@link DefaultCredentialsRefreshServiceBuilder} to create instances.
96+ *
97+ * @param scheduler
98+ * @param refreshDelayStrategy
99+ * @param approachingExpirationStrategy
100+ */
92101 public DefaultCredentialsRefreshService (ScheduledExecutorService scheduler , Function <Duration , Duration > refreshDelayStrategy , Function <Duration , Boolean > approachingExpirationStrategy ) {
93102 if (refreshDelayStrategy == null ) {
94103 throw new IllegalArgumentException ("Refresh delay strategy can not be null" );
@@ -371,6 +380,9 @@ void unregister(String registrationId) {
371380 }
372381 }
373382
383+ /**
384+ * Builder to create instances of {@link DefaultCredentialsRefreshServiceBuilder}.
385+ */
374386 public static class DefaultCredentialsRefreshServiceBuilder {
375387
376388
@@ -385,16 +397,43 @@ public DefaultCredentialsRefreshServiceBuilder scheduler(ScheduledThreadPoolExec
385397 return this ;
386398 }
387399
400+ /**
401+ * Set the strategy to schedule credentials refresh after credentials retrieval.
402+ * <p>
403+ * Default is a 80 % ratio-based strategy (refresh is scheduled after 80 % of the time
404+ * before expiration, e.g. 48 minutes for a token with a validity of 60 minutes, that
405+ * is refresh will be scheduled 12 minutes before the token actually expires).
406+ *
407+ * @param refreshDelayStrategy
408+ * @return this builder instance
409+ * @see DefaultCredentialsRefreshService#refreshDelayStrategy
410+ * @see DefaultCredentialsRefreshService#ratioRefreshDelayStrategy(double)
411+ */
388412 public DefaultCredentialsRefreshServiceBuilder refreshDelayStrategy (Function <Duration , Duration > refreshDelayStrategy ) {
389413 this .refreshDelayStrategy = refreshDelayStrategy ;
390414 return this ;
391415 }
392416
417+ /**
418+ * Set the strategy to trigger an early refresh before attempting to connect.
419+ * <p>
420+ * Default is to never advise to refresh before connecting.
421+ *
422+ * @param approachingExpirationStrategy
423+ * @return this builder instances
424+ * @see DefaultCredentialsRefreshService#approachingExpirationStrategy
425+ * @see CredentialsRefreshService#isApproachingExpiration(Duration)
426+ */
393427 public DefaultCredentialsRefreshServiceBuilder approachingExpirationStrategy (Function <Duration , Boolean > approachingExpirationStrategy ) {
394428 this .approachingExpirationStrategy = approachingExpirationStrategy ;
395429 return this ;
396430 }
397431
432+ /**
433+ * Create the {@link DefaultCredentialsRefreshService} instance.
434+ *
435+ * @return
436+ */
398437 public DefaultCredentialsRefreshService build () {
399438 return new DefaultCredentialsRefreshService (scheduler , refreshDelayStrategy , approachingExpirationStrategy );
400439 }
0 commit comments