Class RevokedTokenCleanerImpl

java.lang.Object
com.example.blogs.app.api.auth.service.RevokedTokenCleanerImpl
All Implemented Interfaces:
RevokedTokenCleaner, SchedulingConfigurer

@Component public class RevokedTokenCleanerImpl extends Object implements RevokedTokenCleaner, SchedulingConfigurer
Configures and executes scheduled cleanup of expired revoked tokens. Uses a cron expression from application configuration to determine cleanup frequency.
  • Constructor Details

    • RevokedTokenCleanerImpl

      public RevokedTokenCleanerImpl(RevokedTokenRepositoryAdapter revokedTokenRepositoryAdapter, @Value("${revoked-token-cleaner.cron}") String cron)
      Constructs a new revoked token cleaner with repository adapter and cron schedule.
      Parameters:
      revokedTokenRepositoryAdapter - adapter for accessing revoked token data
      cron - cron expression defining cleanup schedule (e.g., "0 0 2 * * *" for 2 AM daily)
  • Method Details

    • configureTasks

      public void configureTasks(ScheduledTaskRegistrar taskRegistrar)
      Configures the scheduled task with a dynamic cron trigger. Registers the cleanup task to be executed according to the cron expression.
      Specified by:
      configureTasks in interface SchedulingConfigurer
      Parameters:
      taskRegistrar - Spring's task registrar for scheduling configuration
    • cleanUpExpiredTokens

      public void cleanUpExpiredTokens()
      Executes the cleanup operation by deleting all expired revoked tokens. Called automatically by the Spring scheduler based on the configured cron expression.
      Specified by:
      cleanUpExpiredTokens in interface RevokedTokenCleaner