KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > util > RequestCentricCachePopulator


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.deliver.util;
25
26 import org.apache.log4j.Logger;
27 import org.infoglue.cms.exception.SystemException;
28 import org.infoglue.cms.util.CmsPropertyHandler;
29 import org.infoglue.deliver.applications.databeans.DatabaseWrapper;
30
31
32 public class RequestCentricCachePopulator
33 {
34     public final static Logger logger = Logger.getLogger(RequestCentricCachePopulator.class.getName());
35
36     /**
37      * This method simulates a call to a page so all castor caches fills up before we throw the old page cache.
38      * @param db
39      * @param siteNodeId
40      * @param languageId
41      * @param contentId
42      */

43     
44     public void recache(DatabaseWrapper dbWrapper, Integer JavaDoc siteNodeId) throws SystemException, Exception JavaDoc
45     {
46         logger.info("recache starting..");
47         /*
48         String name = "org.infoglue.deliver.applications.actions.ViewPageAction";
49         Map parameters = new HashMap();
50         parameters.put("siteNodeId", siteNodeId);
51         parameters.put("isRecacheCall", "true");
52
53         FakeHttpServletRequest request = new FakeHttpServletRequest();
54         request.setServletContext(DeliverContextListener.getServletContext());
55         FakeHttpServletResponse response = new FakeHttpServletResponse();
56         
57         HttpServletRequest portalServletRequest = new PortalServletRequest((HttpServletRequest) request);
58         
59         ActionContext.setName(name);
60         ActionContext.setParameters(Collections.unmodifiableMap(parameters));
61         ActionContext.setRequest(portalServletRequest);
62         //ActionContext.setRequest(request);
63         ActionContext.setResponse(response);
64         
65         ViewPageAction action = (ViewPageAction)ActionFactory.getAction(name);
66         action.setServletRequest(portalServletRequest);
67         action.setRecacheCall(true);
68         //action.setServletRequest(request);
69         action.setServletResponse(response);
70
71         String result = null;
72         try
73         {
74            result = (String)action.execute();
75         }
76         catch (Exception e)
77         {
78             e.printStackTrace();
79         }
80         */

81         HttpHelper helper = new HttpHelper();
82         String JavaDoc recacheUrl = CmsPropertyHandler.getRecacheUrl() + "?siteNodeId=" + siteNodeId + "&refresh=true&isRecacheCall=true";
83         //System.out.println("recacheUrl:" + recacheUrl);
84
String JavaDoc response = helper.getUrlContent(recacheUrl);
85         //System.out.println("response:" + response);
86

87         logger.info("recache stopped..");
88     }
89     
90 }
Popular Tags