Only one auditPurgeJob() method is defined, which contains the logic to purge the old audit history
data. Listing 21-21 shows the JPA 2 implementation class.
Listing 21-21. The HousekeepingServiceImpl Class
package com.apress.prospring3.springblog.service.jpa;
import
org.springframework.beans.factory.annotation.Value;
import
org.springframework.scheduling.annotation.Scheduled;
import
org.springframework.stereotype.Repository;
import
org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional;
import com.apress.prospring3.springblog.service.HousekeepingService;
@Service("housekeepingService")
@Repository
@Transactional
public class HousekeepingServiceImpl implements HousekeepingService {
@Value("${audit.record.history.days}")
private int auditHistoryDays;
@Scheduled(cron="0 0 0 * * ?")
public void auditPurgeJob() {
// Purge audit record logic goes here
}
}
In Listing 21-21, the number of days for keeping the audit history is externalized into the
/src/main/resources/springblog.properties file. The auditPurgeJob() is applied with the @Scheduled
annotation to indicate to Spring that it's a scheduled task. The cron expression was used, which means
that the job will run every day at midnight. We leave the logic empty here, but you can imagine it's very
easy to implement. We just need to perform a batch update operation to delete the records from the
ENTRY_H and COMMENT_H tables (in the file schema.sql) for which the create timestamp is older than the
specified number of days.
Presentation Layer
For the presentation layer of the SpringBlog application, basically most of the topics discussed in
Chapter 17 are applied here. Major highlights are summarized here:
Spring MVC will be used for implementing the Model View Controller pattern for
·
the presentation layer, with JSPX as the view technology.
Spring MVC support for i18n, theming, and RESTful-WS (for Ajax-style interaction
·
with jQuery) will be used throughout the presentation layer.
Apache Tiles will be used as the page templating technology. Also, Spring's
·
integration with Apache Tiles will be used for resolving the view to display based
on the logical view names.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home