Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In the SpringBlog application, we will store the history records for both blog posting entries and comments for auditing purposes. However, we also decided to keep only those history records for 30 days in order not to consume too much database storage. To fulfill the requirement, we will adopt Spring 3’s TaskScheduler abstraction support to implement a schedule job to purge the audit records older than 30 days. The job will run every day at midnight.
We will use the annotation style for task scheduling. First we will define an interface for the housekeeping job. Listing 15-17 shows the interface.
Listing 15-17. The HousekeepingService Interface
package com.apress.prospring3.springblog.service;
public interface HousekeepingService {
/**
* Scheduled job to purge audit records.
*/
public void auditPurgeJob();
}