<%-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --%> <%@page import="java.util.List"%> <%@page import="org.apache.commons.jcs3.JCS"%> <%@page import="org.apache.commons.jcs3.access.CacheAccess" %> <%@page import="org.apache.commons.jcs3.admin.CacheElementInfo" %> <%@page import="org.apache.commons.jcs3.admin.CacheRegionInfo" %> <%@page import="org.apache.commons.jcs3.engine.behavior.ICacheElement" %> JCS Administration <% final String CACHE_NAME_PARAM = "cacheName"; final String ACTION_PARAM = "action"; final String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions"; final String CLEAR_REGION_ACTION = "clearRegion"; final String REMOVE_ACTION = "remove"; final String DETAIL_ACTION = "detail"; final String REGION_SUMMARY_ACTION = "regionSummary"; final String ITEM_ACTION = "item"; final String KEY_PARAM = "key"; final String DEFAULT_TEMPLATE_NAME = "DEFAULT"; final String REGION_DETAIL_TEMPLATE_NAME = "DETAIL"; final String ITEM_TEMPLATE_NAME = "ITEM"; final String REGION_SUMMARY_TEMPLATE_NAME = "SUMMARY"; String templateName = DEFAULT_TEMPLATE_NAME; // Get cacheName for actions from request (might be null) String cacheName = request.getParameter(CACHE_NAME_PARAM); if (cacheName != null) { cacheName = cacheName.trim(); } // If an action was provided, handle it String action = request.getParameter(ACTION_PARAM); if (action == null) { // do nothing } else if (action.equals(CLEAR_ALL_REGIONS_ACTION)) { jcsBean.clearAllRegions(); } else if (action.equals(CLEAR_REGION_ACTION) && cacheName != null) { jcsBean.clearRegion(cacheName); } else if (action.equals(REMOVE_ACTION)) { for (String key : request.getParameterValues(KEY_PARAM)) { jcsBean.removeItem(cacheName, key); } templateName = REGION_DETAIL_TEMPLATE_NAME; } else if (action.equals(DETAIL_ACTION)) { templateName = REGION_DETAIL_TEMPLATE_NAME; } else if (action.equals(ITEM_ACTION)) { templateName = ITEM_TEMPLATE_NAME; } else if (action.equals(REGION_SUMMARY_ACTION)) { templateName = REGION_SUMMARY_TEMPLATE_NAME; } /////////////////////////////////////////////////////////////////////////////////// //handle display if (templateName == ITEM_TEMPLATE_NAME) { String key = request.getParameter(KEY_PARAM); if (key != null) { key = key.trim(); } CacheAccess cache = JCS.getInstance(cacheName); ICacheElement element = cache.getCacheElement(key); %>

Item for key [<%=key%>] in region [<%=cacheName%>]

Region Detail | All Regions

<%=element%>
<% } else if (templateName == REGION_SUMMARY_TEMPLATE_NAME) { %>

Summary for region [<%=cacheName%>]

All Regions

<% CacheAccess cache = JCS.getInstance(cacheName); String stats = cache.getStats(); %>

Statistics for region [<%=cacheName%>]

<%=stats%>
<% } else if (templateName == REGION_DETAIL_TEMPLATE_NAME) { %>

Detail for region [<%=cacheName%>]

All Regions

<% for (CacheElementInfo element : jcsBean.buildElementInfo(cacheName)) { %> <% } CacheAccess cache = JCS.getInstance(cacheName); String stats = cache.getStats(); %>
Key Eternal? Create time Max Life (s) Till Expiration (s)
<%=element.getKey()%> <%=element.isEternal()%> <%=element.getCreateTime()%> <%=element.getMaxLifeSeconds()%> <%=element.getExpiresInSeconds()%> View | Remove

Statistics for region [<%=cacheName%>]

<%=stats%>
<% } else { %>

Cache Regions

These are the regions which are currently defined in the cache. 'Items' and 'Bytes' refer to the elements currently in memory (not spooled). You can clear all items for a region by selecting 'Clear' next to the desired region below. You can also Clear all regions which empties the entire cache.

Retrieve from region

<% for (CacheRegionInfo record : records) { %> <% } %>
Cache Name Items Bytes Status Memory Hits Aux Hits Not Found Misses Expired Misses Actions
<%=record.getCacheName()%> <%=record.getCacheSize()%> <%=record.getByteCount()%> <%=record.getCacheStatus()%> <%=record.getHitCountRam()%> <%=record.getHitCountAux()%> <%=record.getMissCountNotFound()%> <%=record.getMissCountExpired()%> Summary | Detail | Clear
<% } %>