This commit is contained in:
Tim
2025-06-15 16:45:27 +02:00
parent 648683c233
commit 5b5a06fff4

View File

@@ -0,0 +1,36 @@
package de.htwsaar.webshop.cronjob;
import de.htwsaar.webshop.service.SessionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import static de.htwsaar.webshop.util.TimeUtil.MILLIS_TO_WEEK;
/**
* CronJob for deleting expired sessions in fixed intervals
*/
@Component
@Slf4j
public class ExpiredSessionDeleteJob {
private final SessionService sessionService;
/**
* Constructor of the class
* @param sessionService used in the class
*/
public ExpiredSessionDeleteJob(SessionService sessionService) {
this.sessionService = sessionService;
}
/**
* Method running the job calling the referring service method
*/
@Scheduled(fixedRate = MILLIS_TO_WEEK)
public void runFixedRateTask() {
log.info("Deleting expired sessions...");
sessionService.deleteExpired();
log.info("Deleted expired sessions.");
}
}