You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2005/12/01 23:12:07 UTC
svn commit: r351502 - in /incubator/roller/trunk: metadata/xdoclet/
src/org/roller/presentation/website/actions/ web/WEB-INF/
web/WEB-INF/classes/ web/website/
Author: agilliland
Date: Thu Dec 1 14:11:59 2005
New Revision: 351502
URL: http://svn.apache.org/viewcvs?rev=351502&view=rev
Log:
adding cache info page to admin section. it's crude, but functional :/
Added:
incubator/roller/trunk/src/org/roller/presentation/website/actions/CacheInfoAction.java
incubator/roller/trunk/web/website/cacheInfo.jsp
Modified:
incubator/roller/trunk/metadata/xdoclet/global-forwards.xml
incubator/roller/trunk/web/WEB-INF/admin-menu.xml
incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
incubator/roller/trunk/web/WEB-INF/tiles-defs.xml
Modified: incubator/roller/trunk/metadata/xdoclet/global-forwards.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/metadata/xdoclet/global-forwards.xml?rev=351502&r1=351501&r2=351502&view=diff
==============================================================================
--- incubator/roller/trunk/metadata/xdoclet/global-forwards.xml (original)
+++ incubator/roller/trunk/metadata/xdoclet/global-forwards.xml Thu Dec 1 14:11:59 2005
@@ -56,6 +56,7 @@
<forward name="commentQueryGlobal" path="/admin/commentQuery.do?method=query"/>
<forward name="addUser" path="/admin/user.do?method=add"/>
<forward name="commonPingTargets" path="/admin/commonPingTargets.do"/>
+<forward name="cacheInfo" path="/admin/cacheInfo.do"/>
<!-- planet admin actions -->
Added: incubator/roller/trunk/src/org/roller/presentation/website/actions/CacheInfoAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/website/actions/CacheInfoAction.java?rev=351502&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/website/actions/CacheInfoAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/website/actions/CacheInfoAction.java Thu Dec 1 14:11:59 2005
@@ -0,0 +1,120 @@
+/*
+ * CacheInfoAction.java
+ *
+ * Created on November 11, 2005, 1:12 PM
+ */
+
+package org.roller.presentation.website.actions;
+
+import java.io.IOException;
+import java.util.Map;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.actions.DispatchAction;
+import org.roller.presentation.BasePageModel;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.RollerSession;
+import org.roller.presentation.cache.CacheManager;
+
+
+/**
+ * Struts Action class which handles requests to the System Info page.
+ *
+ * @struts.action path="/admin/cacheInfo" scope="request" parameter="method"
+ *
+ * @struts.action-forward name="cacheInfo.page" path=".cacheInfo"
+ *
+ * @author Allen Gilliland
+ */
+public class CacheInfoAction extends DispatchAction {
+
+ private static Log mLogger = LogFactory.getLog(CacheInfoAction.class);
+
+
+ public ActionForward unspecified(
+ ActionMapping mapping,
+ ActionForm actionForm,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws IOException, ServletException {
+
+ ActionForward forward = mapping.findForward("cacheInfo.page");
+
+ try {
+ BasePageModel pageModel = new BasePageModel(
+ "cacheInfo.title", request, response, mapping);
+ request.setAttribute("model",pageModel);
+ RollerRequest rreq = RollerRequest.getRollerRequest(request);
+ RollerSession rollerSession = RollerSession.getRollerSession(request);
+ if (rollerSession.isGlobalAdminUser() ) {
+
+ // caching instrumentation
+ Map cacheStats = CacheManager.getStats();
+ request.setAttribute("cacheStats", cacheStats);
+
+ } else {
+ forward = mapping.findForward("access-denied");
+ }
+
+ } catch (Exception e) {
+ mLogger.error("ERROR in action",e);
+ throw new ServletException(e);
+ }
+
+ return forward;
+ }
+
+
+ /**
+ * clear action.
+ *
+ * this is triggered when someone has indicated that they want to clear
+ * one or all of the caches.
+ */
+ public ActionForward clear(
+ ActionMapping mapping,
+ ActionForm actionForm,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws IOException, ServletException {
+
+ ActionForward forward = mapping.findForward("cacheInfo.page");
+
+ try {
+ BasePageModel pageModel = new BasePageModel(
+ "cacheInfo.title", request, response, mapping);
+ request.setAttribute("model",pageModel);
+ RollerRequest rreq = RollerRequest.getRollerRequest(request);
+ RollerSession rollerSession = RollerSession.getRollerSession(request);
+ if (rollerSession.isGlobalAdminUser() ) {
+
+ // see if a specific cache was specified
+ String handlerClass = request.getParameter("cache");
+ if(handlerClass != null && handlerClass.length() > 0) {
+ CacheManager.clear(handlerClass);
+ } else {
+ CacheManager.clear();
+ }
+
+ // caching instrumentation
+ Map cacheStats = CacheManager.getStats();
+ request.setAttribute("cacheStats", cacheStats);
+
+ } else {
+ forward = mapping.findForward("access-denied");
+ }
+
+ } catch (Exception e) {
+ mLogger.error("ERROR in action",e);
+ throw new ServletException(e);
+ }
+
+ return forward;
+ }
+}
Modified: incubator/roller/trunk/web/WEB-INF/admin-menu.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/web/WEB-INF/admin-menu.xml?rev=351502&r1=351501&r2=351502&view=diff
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/admin-menu.xml (original)
+++ incubator/roller/trunk/web/WEB-INF/admin-menu.xml Thu Dec 1 14:11:59 2005
@@ -16,6 +16,8 @@
subforwards="commentQueryGlobal" />
<menu-item forward="commonPingTargets" name="tabbedmenu.admin.pingTargets"
roles="admin" perms="any"/>
+ <menu-item forward="cacheInfo" name="tabbedmenu.admin.cacheInfo"
+ roles="admin" perms="any"/>
</menu>
<menu name="tabbedmenu.planet" roles="admin" perms="any"
Modified: incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties?rev=351502&r1=351501&r2=351502&view=diff
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Thu Dec 1 14:11:59 2005
@@ -1030,6 +1030,13 @@
referers.deletedReferers=Deleted specified referrers
referers.noReferersSpecified=You did not specify any referrers to delete
+# ----------------------------------------------------------------- cacheInfo.jsp
+
+cacheInfo.title=Cache Information
+cacheInfo.subtitle=Monitor cache statistics
+cacheInfo.prompt=This page offers instrumentation data about what is happening \
+in the system caches.
+
# ------------------------------------------------------------------ Tabbed Menu
tabbedmenu.main=Main
@@ -1066,6 +1073,7 @@
tabbedmenu.admin.commentManagement=Comments
tabbedmenu.admin.createUser=New User
tabbedmenu.admin.pingTargets=Ping Targets
+tabbedmenu.admin.cacheInfo=Cache Info
tabbedmenu.planet=Planet Admin
tabbedmenu.admin.planetConfig=Configuration
Modified: incubator/roller/trunk/web/WEB-INF/tiles-defs.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/web/WEB-INF/tiles-defs.xml?rev=351502&r1=351501&r2=351502&view=diff
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/tiles-defs.xml (original)
+++ incubator/roller/trunk/web/WEB-INF/tiles-defs.xml Thu Dec 1 14:11:59 2005
@@ -215,6 +215,9 @@
<definition name=".CommonPingTargets" extends=".tiles-adminpage" >
<put name="content" value="/website/CommonPingTargets.jsp" />
</definition>
+<definition name=".cacheInfo" extends=".tiles-adminpage" >
+ <put name="content" value="/website/cacheInfo.jsp" />
+</definition>
<definition name=".CommonPingTargetDeleteOK" extends=".tiles-simplepage" >
<put name="content" value="/website/CommonPingTargetDeleteOK.jsp" />
Added: incubator/roller/trunk/web/website/cacheInfo.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/web/website/cacheInfo.jsp?rev=351502&view=auto
==============================================================================
--- incubator/roller/trunk/web/website/cacheInfo.jsp (added)
+++ incubator/roller/trunk/web/website/cacheInfo.jsp Thu Dec 1 14:11:59 2005
@@ -0,0 +1,33 @@
+<%@ include file="/taglibs.jsp" %>
+
+<p class="subtitle"><fmt:message key="cacheInfo.subtitle" /></a>
+<p><fmt:message key="cacheInfo.prompt" /></a>
+
+<c:forEach var="cache" items="${cacheStats}">
+ <c:if test="${!empty cache.value}">
+ <table cellspacing="3" border="1">
+ <tr>
+ <th colspan="2"><c:out value="${cache.key}"/></th>
+ </tr>
+
+ <c:forEach var="prop" items="${cache.value}">
+ <tr>
+ <td><c:out value="${prop.key}"/></td>
+ <td><c:out value="${prop.value}"/></td>
+ </tr>
+ </c:forEach>
+
+ <tr>
+ <td colspan="2">
+ <form action="cacheInfo.do" method="POST">
+ <input type="hidden" name="cache" value="<c:out value='${cache.key}'/>">
+ <input type="submit" name="method" value="clear">
+ </form>
+ </td>
+ </tr>
+
+ </table>
+
+ <br>
+ </c:if>
+</c:forEach>
\ No newline at end of file