1 24 package org.riotfamily.cachius.spring; 25 26 import java.util.Map ; 27 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.http.HttpServletResponse ; 30 31 import org.apache.commons.logging.Log; 32 import org.apache.commons.logging.LogFactory; 33 import org.riotfamily.cachius.ItemUpdater; 34 import org.springframework.web.servlet.View; 35 36 37 43 public class CachingView implements View { 44 45 private Log log = LogFactory.getLog(CachingView.class); 46 47 private View view; 48 49 private HttpServletResponse response; 50 51 private ItemUpdater cacheItemUpdate; 52 53 public CachingView(View view, HttpServletResponse response, 54 ItemUpdater cacheItemUpdate) { 55 56 this.view = view; 57 this.response = response; 58 this.cacheItemUpdate = cacheItemUpdate; 59 } 60 61 public String getContentType() { 62 return view.getContentType(); 63 } 64 65 67 public void render(Map model, HttpServletRequest request, 68 HttpServletResponse response) throws Exception { 69 70 if (view != null) { 71 view.render(model, request, this.response); 72 } 73 else { 74 log.debug("No view found!"); 75 } 76 this.response.flushBuffer(); 77 cacheItemUpdate.updateCacheItem(); 78 } 79 80 } 81 | Popular Tags |