| Line 27... |
Line 27... |
| 27 |
*/
|
27 |
*/
|
| 28 |
@SuppressWarnings("serial")
|
28 |
@SuppressWarnings("serial")
|
| 29 |
public class HomeController extends BaseController {
|
29 |
public class HomeController extends BaseController {
|
| 30 |
|
30 |
|
| 31 |
private static Logger logger = Logger.getLogger(Class.class);
|
31 |
private static Logger logger = Logger.getLogger(Class.class);
|
| 32 |
private static final String CACHE_NAME = "HomePageSnippets";
|
- |
|
| 33 |
private static final String BEST_DEALS_CACHE_KEY = "home_best_deals_snippet";
|
32 |
private static final String BEST_DEALS_CACHE_KEY = "home_best_deals_snippet";
|
| 34 |
private static final String BEST_SELLERS_CACHE_KEY = "home_best_sellers_snippet";
|
33 |
private static final String BEST_SELLERS_CACHE_KEY = "home_best_sellers_snippet";
|
| 35 |
private static final String LATEST_ARRIVALS_CACHE_KEY = "home_latest_arrivals_snippet";
|
34 |
private static final String LATEST_ARRIVALS_CACHE_KEY = "home_latest_arrivals_snippet";
|
| 36 |
|
- |
|
| 37 |
|
- |
|
| 38 |
|
35 |
|
| 39 |
private List<String> bestDealSnippets = null;
|
36 |
private List<String> bestDealSnippets = null;
|
| 40 |
private List<String> bestSellerSnippets = null;
|
37 |
private List<String> bestSellerSnippets = null;
|
| 41 |
private List<String> latestArrivalSnippets = null;
|
38 |
private List<String> latestArrivalSnippets = null;
|
| 42 |
|
39 |
|
| Line 72... |
Line 69... |
| 72 |
*/
|
69 |
*/
|
| 73 |
@Action("/refresh-home")
|
70 |
@Action("/refresh-home")
|
| 74 |
public String destroy() throws SecurityException, IOException{
|
71 |
public String destroy() throws SecurityException, IOException{
|
| 75 |
logger.info("Reloading best deals, best sellers and latest arrivals");
|
72 |
logger.info("Reloading best deals, best sellers and latest arrivals");
|
| 76 |
EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
|
73 |
EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
|
| 77 |
CACHE_NAME, CacheManager.create());
|
74 |
EhcacheWrapper.HOME_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
|
| 78 |
homeSnippetCache.removeAll();
|
75 |
homeSnippetCache.removeAll();
|
| 79 |
setSnippets();
|
76 |
setSnippets();
|
| 80 |
return "index";
|
77 |
return "index";
|
| 81 |
}
|
78 |
}
|
| 82 |
|
79 |
|
| Line 96... |
Line 93... |
| 96 |
* Loads the snippets for best deals, best sellers and latest arrivals
|
93 |
* Loads the snippets for best deals, best sellers and latest arrivals
|
| 97 |
* into memory.
|
94 |
* into memory.
|
| 98 |
*/
|
95 |
*/
|
| 99 |
private void setSnippets() {
|
96 |
private void setSnippets() {
|
| 100 |
EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
|
97 |
EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
|
| 101 |
CACHE_NAME, CacheManager.create());
|
98 |
EhcacheWrapper.HOME_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
|
| 102 |
bestDealSnippets = homeSnippetCache.get(BEST_DEALS_CACHE_KEY);
|
99 |
bestDealSnippets = homeSnippetCache.get(BEST_DEALS_CACHE_KEY);
|
| 103 |
bestSellerSnippets = homeSnippetCache.get(BEST_SELLERS_CACHE_KEY);
|
100 |
bestSellerSnippets = homeSnippetCache.get(BEST_SELLERS_CACHE_KEY);
|
| 104 |
latestArrivalSnippets = homeSnippetCache.get(LATEST_ARRIVALS_CACHE_KEY);
|
101 |
latestArrivalSnippets = homeSnippetCache.get(LATEST_ARRIVALS_CACHE_KEY);
|
| 105 |
|
102 |
|
| 106 |
if (bestDealSnippets != null && bestSellerSnippets != null && latestArrivalSnippets != null) {
|
103 |
if (bestDealSnippets != null && bestSellerSnippets != null && latestArrivalSnippets != null) {
|